home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / shlobj.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-09  |  98.0 KB  |  2,456 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       Windows 32bit API Interface Unit                }
  6. {                                                       }
  7. {       Copyright (c) 1996,98 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit ShlObj;
  12.  
  13. {$WEAKPACKAGEUNIT}
  14.  
  15. interface
  16.  
  17. uses Windows, ActiveX, CommCtrl, ShellAPI, RegStr, Messages;
  18.  
  19. {$HPPEMIT '#include <ole2.h>'}
  20. {$HPPEMIT '#include <prsht.h>'}
  21. {$HPPEMIT '#include <commctrl.h>   // for LPTBBUTTON'}
  22. {$HPPEMIT '#include <shlguid.h>'}
  23. {$HPPEMIT '#include <shlobj.h>'}
  24.  
  25. {$HPPEMIT 'typedef System::DelphiInterface<IAdviseSink> _di_IAdviseSink;'}
  26. {$HPPEMIT 'typedef System::DelphiInterface<IShellBrowser> _di_IShellBrowser;'}
  27. {$HPPEMIT 'typedef System::DelphiInterface<IShellView> _di_IShellView;'}
  28. {$HPPEMIT 'typedef System::DelphiInterface<IContextMenu> _di_IContextMenu;'}
  29. {$HPPEMIT 'typedef System::DelphiInterface<IShellIcon> _di_IShellIcon;'}
  30. {$HPPEMIT 'typedef System::DelphiInterface<IShellFolder> _di_IShellFolder;'}
  31. {$HPPEMIT 'typedef System::DelphiInterface<IShellExtInit> _di_IShellExtInit;'}
  32. {$HPPEMIT 'typedef System::DelphiInterface<IShellPropSheetExt> _di_IShellPropSheetExt;'}
  33. {$HPPEMIT 'typedef System::DelphiInterface<IPersistFolder> _di_IPersistFolder;'}
  34. {$HPPEMIT 'typedef System::DelphiInterface<ICommDlgBrowser> _di_ICommDlgBrowser;'}
  35. {$HPPEMIT 'typedef System::DelphiInterface<IEnumIDList> _di_IEnumIDList;'}
  36. {$HPPEMIT 'typedef System::DelphiInterface<IFileViewerSite> _di_IFileViewerSite;'}
  37. {$HPPEMIT 'typedef System::DelphiInterface<IContextMenu2> _di_IContextMenu2;'}
  38. {$HPPEMIT 'typedef System::DelphiInterface<IShellView2> _di_IShellView2;'}
  39. {$HPPEMIT 'typedef System::DelphiInterface<INewShortcutHookA> _di_INewShortcutHookA;'}
  40. {$HPPEMIT 'typedef System::DelphiInterface<INewShortcutHookW> _di_INewShortcutHookW;'}
  41. {$HPPEMIT 'typedef System::DelphiInterface<IFileViewerA> _di_IFileViewerA;'}
  42. {$HPPEMIT 'typedef System::DelphiInterface<IFileViewerW> _di_IFileViewerW;'}
  43. {$HPPEMIT 'typedef System::DelphiInterface<IShellLinkA> _di_IShellLinkA;'}
  44. {$HPPEMIT 'typedef System::DelphiInterface<IShellLinkW> _di_IShellLinkW;'}
  45. {$HPPEMIT 'typedef System::DelphiInterface<IExtractIconA> _di_IExtractIconA;'}
  46. {$HPPEMIT 'typedef System::DelphiInterface<IExtractIconW> _di_IExtractIconW;'}
  47. {$HPPEMIT 'typedef System::DelphiInterface<IShellExecuteHookA> _di_IShellExecuteHookA;'}
  48. {$HPPEMIT 'typedef System::DelphiInterface<IShellExecuteHookW> _di_IShellExecuteHookW;'}
  49. {$HPPEMIT 'typedef System::DelphiInterface<ICopyHookA> _di_ICopyHookA;'}
  50. {$HPPEMIT 'typedef System::DelphiInterface<ICopyHookW> _di_ICopyHookW;'}
  51.  
  52. {$HPPEMIT '#ifdef UNICODE'}
  53. {$HPPEMIT 'typedef _di_INewShortcutHookW _di_INewShortcutHook;'}
  54. {$HPPEMIT 'typedef _di_IFileViewerW _di_IFileViewer;'}
  55. {$HPPEMIT 'typedef _di_IShellLinkW _di_IShellLink;'}
  56. {$HPPEMIT 'typedef _di_IExtractIconW _di_IExtractIcon;'}
  57. {$HPPEMIT 'typedef _di_IShellExecuteHookW _di_IShellExecuteHook;'}
  58. {$HPPEMIT 'typedef _di_ICopyHookW _di_ICopyHook;'}
  59. {$HPPEMIT '#else'}
  60. {$HPPEMIT 'typedef _di_INewShortcutHookA _di_INewShortcutHook;'}
  61. {$HPPEMIT 'typedef _di_IFileViewerA _di_IFileViewer;'}
  62. {$HPPEMIT 'typedef _di_IShellLinkA _di_IShellLink;'}
  63. {$HPPEMIT 'typedef _di_IExtractIconA _di_IExtractIcon;'}
  64. {$HPPEMIT 'typedef _di_IShellExecuteHookA _di_IShellExecuteHook;'}
  65. {$HPPEMIT 'typedef _di_ICopyHookA _di_ICopyHook;'}
  66. {$HPPEMIT '#endif'}
  67.  
  68. { Object identifiers in the explorer's name space (ItemID and IDList)
  69.   All the items that the user can browse with the explorer (such as files,
  70.   directories, servers, work-groups, etc.) has an identifier which is unique
  71.   among items within the parent folder. Those identifiers are called item
  72.   IDs (SHITEMID). Since all its parent folders have their own item IDs,
  73.   any items can be uniquely identified by a list of item IDs, which is called
  74.   an ID list (ITEMIDLIST).
  75.  
  76.   ID lists are almost always allocated by the task allocator (see some
  77.   description below as well as OLE 2.0 SDK) and may be passed across
  78.   some of shell interfaces (such as IShellFolder). Each item ID in an ID list
  79.   is only meaningful to its parent folder (which has generated it), and all
  80.   the clients must treat it as an opaque binary data except the first two
  81.   bytes, which indicates the size of the item ID.
  82.  
  83.   When a shell extension -- which implements the IShellFolder interace --
  84.   generates an item ID, it may put any information in it, not only the data
  85.   with that it needs to identifies the item, but also some additional
  86.   information, which would help implementing some other functions efficiently.
  87.   For example, the shell's IShellFolder implementation of file system items
  88.   stores the primary (long) name of a file or a directory as the item
  89.   identifier, but it also stores its alternative (short) name, size and date
  90.   etc.
  91.  
  92.   When an ID list is passed to one of shell APIs (such as SHGetPathFromIDList),
  93.   it is always an absolute path -- relative from the root of the name space,
  94.   which is the desktop folder. When an ID list is passed to one of IShellFolder
  95.   member function, it is always a relative path from the folder (unless it
  96.   is explicitly specified). }
  97.  
  98. const
  99. // Class IDs        xx=00-9F
  100.   {$EXTERNALSYM CLSID_ShellDesktop}
  101.   CLSID_ShellDesktop: TGUID = (
  102.     D1:$00021400; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  103.   {$EXTERNALSYM CLSID_ShellLink}
  104.   CLSID_ShellLink: TGUID = (
  105.     D1:$00021401; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  106.  
  107. // Format IDs       xx=A0-CF
  108.   {$EXTERNALSYM FMTID_Intshcut}
  109.   FMTID_Intshcut: TGUID = (
  110.     D1:$000214A0; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  111.   {$EXTERNALSYM FMTID_InternetSite}
  112.   FMTID_InternetSite: TGUID = (
  113.     D1:$000214A1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  114.  
  115. // command group ids xx=D0-DF
  116.   {$EXTERNALSYM CGID_Explorer}
  117.   CGID_Explorer: TGUID = (
  118.     D1:$000214D0; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  119.   {$EXTERNALSYM CGID_ShellDocView}
  120.   CGID_ShellDocView: TGUID = (
  121.     D1:$000214D1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  122.  
  123. // Interface IDs    xx=E0-FF
  124.   {$EXTERNALSYM IID_INewShortcutHookA}
  125.   IID_INewShortcutHookA: TGUID = (
  126.     D1:$000214E1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  127.   {$EXTERNALSYM IID_IShellBrowser}
  128.   IID_IShellBrowser: TGUID = (
  129.     D1:$000214E2; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  130.   {$EXTERNALSYM IID_IShellView}
  131.   IID_IShellView: TGUID = (
  132.     D1:$000214E3; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  133.   {$EXTERNALSYM IID_IContextMenu}
  134.   IID_IContextMenu: TGUID = (
  135.     D1:$000214E4; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  136.   {$EXTERNALSYM IID_IShellIcon}
  137.   IID_IShellIcon: TGUID = (
  138.     D1:$000214E5; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  139.   {$EXTERNALSYM IID_IShellFolder}
  140.   IID_IShellFolder: TGUID = (
  141.     D1:$000214E6; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  142.   {$EXTERNALSYM IID_IShellExtInit}
  143.   IID_IShellExtInit: TGUID = (
  144.     D1:$000214E8; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  145.   {$EXTERNALSYM IID_IShellPropSheetExt}
  146.   IID_IShellPropSheetExt: TGUID = (
  147.     D1:$000214E9; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  148.   {$EXTERNALSYM IID_IPersistFolder}
  149.   IID_IPersistFolder: TGUID = (
  150.     D1:$000214EA; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  151.   {$EXTERNALSYM IID_IExtractIconA}
  152.   IID_IExtractIconA: TGUID = (
  153.     D1:$000214EB; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  154.   {$EXTERNALSYM IID_IShellLinkA}
  155.   IID_IShellLinkA: TGUID = (
  156.     D1:$000214EE; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  157.   {$EXTERNALSYM IID_IShellCopyHookA}
  158.   IID_IShellCopyHookA: TGUID = (
  159.     D1:$000214EF; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  160.   {$EXTERNALSYM IID_IFileViewerA}
  161.   IID_IFileViewerA: TGUID = (
  162.     D1:$000214F0; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  163.   {$EXTERNALSYM IID_ICommDlgBrowser}
  164.   IID_ICommDlgBrowser: TGUID = (
  165.     D1:$000214F1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  166.   {$EXTERNALSYM IID_IEnumIDList}
  167.   IID_IEnumIDList: TGUID = (
  168.     D1:$000214F2; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  169.   {$EXTERNALSYM IID_IFileViewerSite}
  170.   IID_IFileViewerSite: TGUID = (
  171.     D1:$000214F3; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  172.   {$EXTERNALSYM IID_IContextMenu2}
  173.   IID_IContextMenu2: TGUID = (
  174.     D1:$000214F4; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  175.   {$EXTERNALSYM IID_IShellExecuteHook}
  176.   IID_IShellExecuteHook: TGUID = (
  177.     D1:$000214F5; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  178.   {$EXTERNALSYM IID_IPropSheetPage}
  179.   IID_IPropSheetPage: TGUID = (
  180.     D1:$000214F6; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  181.   {$EXTERNALSYM IID_INewShortcutHookW}
  182.   IID_INewShortcutHookW: TGUID = (
  183.     D1:$000214F7; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  184.   {$EXTERNALSYM IID_IFileViewerW}
  185.   IID_IFileViewerW: TGUID = (
  186.     D1:$000214F8; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  187.   {$EXTERNALSYM IID_IShellLinkW}
  188.   IID_IShellLinkW: TGUID = (
  189.     D1:$000214F9; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  190.   {$EXTERNALSYM IID_IExtractIconW}
  191.   IID_IExtractIconW: TGUID = (
  192.     D1:$000214FA; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  193.   {$EXTERNALSYM IID_IShellExecuteHookW}
  194.   IID_IShellExecuteHookW: TGUID = (
  195.     D1:$000214FB; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  196.   {$EXTERNALSYM IID_IShellCopyHookW}
  197.   IID_IShellCopyHookW: TGUID = (
  198.     D1:$000214FC; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  199.   {$EXTERNALSYM IID_IShellView2}
  200.   IID_IShellView2: TGUID = (
  201.     D1:$88E39E80; D2:$3578; D3:$11CF; D4:($AE,$69,$08,$00,$2B,$2E,$12,$62));
  202.  
  203. // String constants for Interface IDs
  204.   SID_INewShortcutHookA  = '{000214E1-0000-0000-C000-000000000046}';
  205.   SID_IShellBrowser      = '{000214E2-0000-0000-C000-000000000046}';
  206.   SID_IShellView         = '{000214E3-0000-0000-C000-000000000046}';
  207.   SID_IContextMenu       = '{000214E4-0000-0000-C000-000000000046}';
  208.   SID_IShellIcon         = '{000214E5-0000-0000-C000-000000000046}';
  209.   SID_IShellFolder       = '{000214E6-0000-0000-C000-000000000046}';
  210.   SID_IShellExtInit      = '{000214E8-0000-0000-C000-000000000046}';
  211.   SID_IShellPropSheetExt = '{000214E9-0000-0000-C000-000000000046}';
  212.   SID_IPersistFolder     = '{000214EA-0000-0000-C000-000000000046}';
  213.   SID_IExtractIconA      = '{000214EB-0000-0000-C000-000000000046}';
  214.   SID_IShellLinkA        = '{000214EE-0000-0000-C000-000000000046}';
  215.   SID_IShellCopyHookA    = '{000214EF-0000-0000-C000-000000000046}';
  216.   SID_IFileViewerA       = '{000214F0-0000-0000-C000-000000000046}';
  217.   SID_ICommDlgBrowser    = '{000214F1-0000-0000-C000-000000000046}';
  218.   SID_IEnumIDList        = '{000214F2-0000-0000-C000-000000000046}';
  219.   SID_IFileViewerSite    = '{000214F3-0000-0000-C000-000000000046}';
  220.   SID_IContextMenu2      = '{000214F4-0000-0000-C000-000000000046}';
  221.   SID_IShellExecuteHookA = '{000214F5-0000-0000-C000-000000000046}';
  222.   SID_IPropSheetPage     = '{000214F6-0000-0000-C000-000000000046}';
  223.   SID_INewShortcutHookW  = '{000214F7-0000-0000-C000-000000000046}';
  224.   SID_IFileViewerW       = '{000214F8-0000-0000-C000-000000000046}';
  225.   SID_IShellLinkW        = '{000214F9-0000-0000-C000-000000000046}';
  226.   SID_IExtractIconW      = '{000214FA-0000-0000-C000-000000000046}';
  227.   SID_IShellExecuteHookW = '{000214FB-0000-0000-C000-000000000046}';
  228.   SID_IShellCopyHookW    = '{000214FC-0000-0000-C000-000000000046}';
  229.   SID_IShellView2        = '{88E39E80-3578-11CF-AE69-08002B2E1262}';
  230.  
  231. type
  232. { TSHItemID -- Item ID }
  233.   PSHItemID = ^TSHItemID;
  234.   {$EXTERNALSYM _SHITEMID}
  235.   _SHITEMID = record
  236.     cb: Word;                         { Size of the ID (including cb itself) }
  237.     abID: array[0..0] of Byte;        { The item ID (variable length) }
  238.   end;
  239.   TSHItemID = _SHITEMID;
  240.   {$EXTERNALSYM SHITEMID}
  241.   SHITEMID = _SHITEMID;
  242.  
  243.  
  244. { TItemIDList -- List if item IDs (combined with 0-terminator) }
  245.   PItemIDList = ^TItemIDList;
  246.   {$EXTERNALSYM _ITEMIDLIST}
  247.   _ITEMIDLIST = record
  248.      mkid: TSHItemID;
  249.    end;
  250.   TItemIDList = _ITEMIDLIST;
  251.   {$EXTERNALSYM ITEMIDLIST}
  252.   ITEMIDLIST = _ITEMIDLIST;
  253.  
  254.  
  255. { Task allocator API }
  256.  
  257. { All the shell extensions MUST use the task allocator (see OLE 2.0
  258.  programming guild for its definition) when they allocate or free
  259.  memory objects (mostly ITEMIDLIST) that are returned across any
  260.  shell interfaces. There are two ways to access the task allocator
  261.  from a shell extension depending on whether or not it is linked with
  262.  OLE32.DLL or not (virtual; stdcall; abstractly for efficiency).
  263.  
  264.  (1) A shell extension which calls any OLE API (i.e., linked with
  265.   OLE32.DLL) should call OLE's task allocator (by retrieving
  266.   the task allocator by calling CoGetMalloc API).
  267.  
  268.  (2) A shell extension which does not call any OLE API (i.e., not linked
  269.   with OLE32.DLL) should call the shell task allocator API (defined
  270.   below), so that the shell can quickly loads it when OLE32.DLL is not
  271.   loaded by any application at that point. }
  272.  
  273. { !!! Notes:
  274.   In next version of Windowso release, SHGetMalloc will be replaced by
  275.  the following macro.
  276.  
  277.  #define SHGetMalloc(ppmem)     CoGetMalloc(MEMCTX_TASK, ppmem) }
  278.  
  279. {$EXTERNALSYM SHGetMalloc}
  280. function SHGetMalloc(var ppMalloc: IMalloc): HResult; stdcall;
  281.  
  282. { IContextMenu interface }
  283.  
  284. { [OverView] }
  285.  
  286. { The shell uses the IContextMenu interface in following three cases.
  287.  
  288.  case-1: The shell is loading context menu extensions.
  289.    When the user clicks the right mouse button on an item within the shell's
  290.   name space (i.g., file, directory, server, work-group, etc.), it creates
  291.   the default context menu for its type, then loads context menu extensions
  292.   that are registered for that type (and its base type) so that they can
  293.   add extra menu items. Those context menu extensions are registered at
  294.   HKCR\beginProgIDend\shellex\ContextMenuHandlers.
  295.  
  296.  case-2: The shell is retrieving a context menu of sub-folders in extended
  297.    name-space.
  298.    When the explorer's name space is extended by name space extensions,
  299.   the shell calls their IShellFolder::GetUIObjectOf to get the IContextMenu
  300.   objects when it creates context menus for folders under those extended
  301.   name spaces.
  302.  
  303.  case-3: The shell is loading non-default drag and drop handler for directories.
  304.    When the user performed a non-default drag and drop onto one of file
  305.   system folders (i.e., directories), it loads shell extensions that are
  306.   registered at HKCR\beginProgIDend\DragDropHandlers. }
  307.  
  308. { [Member functions] }
  309.  
  310. { IContextMenu::QueryContextMenu }
  311.  
  312. { This member function may insert one or more menuitems to the specified
  313.   menu (hmenu) at the specified location (indexMenu which is never be -1).
  314.   The IDs of those menuitem must be in the specified range (idCmdFirst and
  315.   idCmdLast). It returns the maximum menuitem ID offset (ushort) in the
  316.   'code' field (low word) of the scode.
  317.  
  318.   The uFlags specify the context. It may have one or more of following
  319.   flags.
  320.  
  321.   CMF_DEFAULTONLY: This flag is passed if the user is invoking the default
  322.   action (typically by double-clicking, case 1 and 2 only). Context menu
  323.   extensions (case 1) should not add any menu items, and returns NOERROR.
  324.  
  325.   CMF_VERBSONLY: The explorer passes this flag if it is constructing
  326.   a context menu for a short-cut object (case 1 and case 2 only). If this
  327.   flag is passed, it should not add any menu-items that is not appropriate
  328.   from a short-cut.
  329.   A good example is the 'Delete' menuitem, which confuses the user
  330.   because it is not clear whether it deletes the link source item or the
  331.   link itself.
  332.  
  333.   CMF_EXPLORER: The explorer passes this flag if it has the left-side pane
  334.    (case 1 and 2 only). Context menu extensions should ignore this flag.
  335.  
  336.   High word (16-bit) are reserved for context specific communications
  337.   and the rest of flags (13-bit) are reserved by the system. }
  338.  
  339.  
  340. { IContextMenu::InvokeCommand }
  341.  
  342. { This member is called when the user has selected one of menuitems that
  343.   are inserted by previous QueryContextMenu member. In this case, the
  344.   LOWORD(lpici->lpVerb) contains the menuitem ID offset (menuitem ID -
  345.   idCmdFirst).
  346.  
  347.    This member function may also be called programmatically. In such a case,
  348.   lpici->lpVerb specifies the canonical name of the command to be invoked,
  349.   which is typically retrieved by GetCommandString member previously.
  350.  
  351.   Parameters in lpci:
  352.     cbSize -- Specifies the size of this structure (sizeof(*lpci))
  353.     hwnd   -- Specifies the owner window for any message/dialog box.
  354.     fMask  -- Specifies whether or not dwHotkey/hIcon paramter is valid.
  355.     lpVerb -- Specifies the command to be invoked.
  356.     lpParameters -- Parameters (optional)
  357.     lpDirectory  -- Working directory (optional)
  358.     nShow -- Specifies the flag to be passed to ShowWindow (SW_*).
  359.     dwHotKey -- Hot key to be assigned to the app after invoked (optional).
  360.     hIcon -- Specifies the icon (optional). }
  361.  
  362.  
  363. { IContextMenu::GetCommandString }
  364.  
  365. { This member function is called by the explorer either to get the
  366.   canonical (language independent) command name (uFlags == GCS_VERB) or
  367.   the help text ((uFlags & GCS_HELPTEXT) != 0) for the specified command.
  368.   The retrieved canonical string may be passed to its InvokeCommand
  369.   member function to invoke a command programmatically. The explorer
  370.   displays the help texts in its status bar; therefore, the length of
  371.   the help text should be reasonably short (<40 characters).
  372.  
  373.   Parameters:
  374.    idCmd -- Specifies menuitem ID offset (from idCmdFirst)
  375.    uFlags -- Either GCS_VERB or GCS_HELPTEXT
  376.    pwReserved -- Reserved (must pass NULL when calling, must ignore when called)
  377.    pszName -- Specifies the string buffer.
  378.    cchMax -- Specifies the size of the string buffer. }
  379.  
  380.  
  381. const
  382. { QueryContextMenu uFlags }
  383.  
  384.   {$EXTERNALSYM CMF_NORMAL}
  385.   CMF_NORMAL             = $00000000;
  386.   {$EXTERNALSYM CMF_DEFAULTONLY}
  387.   CMF_DEFAULTONLY        = $00000001;
  388.   {$EXTERNALSYM CMF_VERBSONLY}
  389.   CMF_VERBSONLY          = $00000002;
  390.   {$EXTERNALSYM CMF_EXPLORE}
  391.   CMF_EXPLORE            = $00000004;
  392.   {$EXTERNALSYM CMF_NOVERBS}
  393.   CMF_NOVERBS            = $00000008;
  394.   {$EXTERNALSYM CMF_CANRENAME}
  395.   CMF_CANRENAME          = $00000010;
  396.   {$EXTERNALSYM CMF_NODEFAULT}
  397.   CMF_NODEFAULT          = $00000020;
  398.   {$EXTERNALSYM CMF_INCLUDESTATIC}
  399.   CMF_INCLUDESTATIC      = $00000040;
  400.   {$EXTERNALSYM CMF_RESERVED}
  401.   CMF_RESERVED           = $FFFF0000;      { View specific }
  402.  
  403. { GetCommandString uFlags }
  404.  
  405.   {$EXTERNALSYM GCS_VERBA}
  406.   GCS_VERBA            = $00000000;     { canonical verb }
  407.   {$EXTERNALSYM GCS_HELPTEXTA}
  408.   GCS_HELPTEXTA        = $00000001;     { help text (for status bar) }
  409.   {$EXTERNALSYM GCS_VALIDATEA}
  410.   GCS_VALIDATEA        = $00000002;     { validate command exists }
  411.   {$EXTERNALSYM GCS_VERBW}
  412.   GCS_VERBW            = $00000004;     { canonical verb (unicode) }
  413.   {$EXTERNALSYM GCS_HELPTEXTW}
  414.   GCS_HELPTEXTW        = $00000005;     { help text (unicode version) }
  415.   {$EXTERNALSYM GCS_VALIDATEW}
  416.   GCS_VALIDATEW        = $00000006;     { validate command exists (unicode) }
  417.   {$EXTERNALSYM GCS_UNICODE}
  418.   GCS_UNICODE          = $00000004;     { for bit testing - Unicode string }
  419.  
  420. {$IFDEF UNICODE}
  421.   {$EXTERNALSYM GCS_VERB}
  422.   GCS_VERB            = GCS_VERBW;
  423.   {$EXTERNALSYM GCS_HELPTEXT}
  424.   GCS_HELPTEXT        = GCS_HELPTEXTW;
  425.   {$EXTERNALSYM GCS_VALIDATE}
  426.   GCS_VALIDATE        = GCS_VALIDATEW;
  427. {$ELSE}
  428.   {$EXTERNALSYM GCS_VERB}
  429.   GCS_VERB            = GCS_VERBA;
  430.   {$EXTERNALSYM GCS_HELPTEXT}
  431.   GCS_HELPTEXT        = GCS_HELPTEXTA;
  432.   {$EXTERNALSYM GCS_VALIDATE}
  433.   GCS_VALIDATE        = GCS_VALIDATEA;
  434. {$ENDIF}
  435.  
  436.   {$EXTERNALSYM CMDSTR_NEWFOLDERA}
  437.   CMDSTR_NEWFOLDERA       = 'NewFolder';
  438.   {$EXTERNALSYM CMDSTR_VIEWLISTA}
  439.   CMDSTR_VIEWLISTA        = 'ViewList';
  440.   {$EXTERNALSYM CMDSTR_VIEWDETAILSA}
  441.   CMDSTR_VIEWDETAILSA     = 'ViewDetails';
  442.   {$EXTERNALSYM CMDSTR_NEWFOLDERW}
  443.   CMDSTR_NEWFOLDERW       = 'NewFolder'; // !!! make WideString() ?
  444.   {$EXTERNALSYM CMDSTR_VIEWLISTW}
  445.   CMDSTR_VIEWLISTW        = 'ViewList';
  446.   {$EXTERNALSYM CMDSTR_VIEWDETAILSW}
  447.   CMDSTR_VIEWDETAILSW     = 'ViewDetails';
  448.  
  449. {$IFDEF UNICODE}
  450.   {$EXTERNALSYM CMDSTR_NEWFOLDER}
  451.   CMDSTR_NEWFOLDER        = CMDSTR_NEWFOLDERW;
  452.   {$EXTERNALSYM CMDSTR_VIEWLIST}
  453.   CMDSTR_VIEWLIST         = CMDSTR_VIEWLISTW;
  454.   {$EXTERNALSYM CMDSTR_VIEWDETAILS}
  455.   CMDSTR_VIEWDETAILS      = CMDSTR_VIEWDETAILSW;
  456. {$ELSE}
  457.   {$EXTERNALSYM CMDSTR_NEWFOLDER}
  458.   CMDSTR_NEWFOLDER        = CMDSTR_NEWFOLDERA;
  459.   {$EXTERNALSYM CMDSTR_VIEWLIST}
  460.   CMDSTR_VIEWLIST         = CMDSTR_VIEWLISTA;
  461.   {$EXTERNALSYM CMDSTR_VIEWDETAILS}
  462.   CMDSTR_VIEWDETAILS      = CMDSTR_VIEWDETAILSA;
  463. {$ENDIF}
  464.  
  465.   {$EXTERNALSYM CMIC_MASK_HOTKEY}
  466.   CMIC_MASK_HOTKEY            = SEE_MASK_HOTKEY;
  467.   {$EXTERNALSYM CMIC_MASK_ICON}
  468.   CMIC_MASK_ICON              = SEE_MASK_ICON;
  469.   {$EXTERNALSYM CMIC_MASK_FLAG_NO_UI}
  470.   CMIC_MASK_FLAG_NO_UI        = SEE_MASK_FLAG_NO_UI;
  471.   {$EXTERNALSYM CMIC_MASK_UNICODE}
  472.   CMIC_MASK_UNICODE           = SEE_MASK_UNICODE;
  473.   {$EXTERNALSYM CMIC_MASK_NO_CONSOLE}
  474.   CMIC_MASK_NO_CONSOLE        = SEE_MASK_NO_CONSOLE;
  475. //  CMIC_MASK_HASLINKNAME       = SEE_MASK_HASLINKNAME; - not defined in shellapi
  476. //  CMIC_MASK_FLAG_SEP_VDM      = SEE_MASK_FLAG_SEPVDM; - not defined in shellapi
  477. //  CMIC_MASK_HASTITLE          = SEE_MASK_HASTITLE; - not defined in shellapi
  478.   {$EXTERNALSYM CMIC_MASK_ASYNCOK}
  479.   CMIC_MASK_ASYNCOK           = SEE_MASK_ASYNCOK;
  480.  
  481. type
  482.   PCMInvokeCommandInfo = ^TCMInvokeCommandInfo;
  483.   {$EXTERNALSYM _CMINVOKECOMMANDINFO}
  484.   _CMINVOKECOMMANDINFO = record
  485.     cbSize: DWORD;        { must be sizeof(CMINVOKECOMMANDINFO) }
  486.     fMask: DWORD;         { any combination of CMIC_MASK_* }
  487.     hwnd: HWND;           { might be NULL (indicating no owner window) }
  488.     lpVerb: LPCSTR;       { either a string of MAKEINTRESOURCE(idOffset) }
  489.     lpParameters: LPCSTR; { might be NULL (indicating no parameter) }
  490.     lpDirectory: LPCSTR;  { might be NULL (indicating no specific directory) }
  491.     nShow: Integer;       { one of SW_ values for ShowWindow() API }
  492.     dwHotKey: DWORD;
  493.     hIcon: THandle;
  494.   end;
  495.   TCMInvokeCommandInfo = _CMINVOKECOMMANDINFO;
  496.   {$EXTERNALSYM CMINVOKECOMMANDINFO}
  497.   CMINVOKECOMMANDINFO = _CMINVOKECOMMANDINFO;
  498.  
  499.   PCMInvokeCommandInfoEx = ^TCMInvokeCommandInfoEx;
  500.   {$EXTERNALSYM _CMInvokeCommandInfoEx}
  501.   _CMInvokeCommandInfoEx = record
  502.     cbSize: DWORD;       { must be sizeof(CMINVOKECOMMANDINFOEX) }
  503.     fMask: DWORD;        { any combination of CMIC_MASK_* }
  504.     hwnd: HWND;          { might be NULL (indicating no owner window) }
  505.     lpVerb: LPCSTR;      { either a string or MAKEINTRESOURCE(idOffset) }
  506.     lpParameters: LPCSTR;{ might be NULL (indicating no parameter) }
  507.     lpDirectory: LPCSTR; { might be NULL (indicating no specific directory) }
  508.     nShow: Integer;       { one of SW_ values for ShowWindow() API }
  509.     dwHotKey: DWORD;
  510.     hIcon: THandle;
  511.     lpTitle: LPCSTR;     { For CreateProcess-StartupInfo.lpTitle }
  512.     lpVerbW: LPCWSTR;       { Unicode verb (for those who can use it) }
  513.     lpParametersW: LPCWSTR; { Unicode parameters (for those who can use it) }
  514.     lpDirectoryW: LPCWSTR;  { Unicode directory (for those who can use it) }
  515.     lpTitleW: LPCWSTR;      { Unicode title (for those who can use it) }
  516.   end;
  517.   TCMInvokeCommandInfoEx = _CMINVOKECOMMANDINFOEX;
  518.   {$EXTERNALSYM CMINVOKECOMMANDINFOEX}
  519.   CMINVOKECOMMANDINFOEX = _CMINVOKECOMMANDINFOEX;
  520.  
  521.  
  522.   {$EXTERNALSYM IContextMenu}
  523.   IContextMenu = interface(IUnknown)
  524.     [SID_IContextMenu]
  525.     function QueryContextMenu(Menu: HMENU;
  526.       indexMenu, idCmdFirst, idCmdLast, uFlags: UINT): HResult; stdcall;
  527.     function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult; stdcall;
  528.     function GetCommandString(idCmd, uType: UINT; pwReserved: PUINT;
  529.       pszName: LPSTR; cchMax: UINT): HResult; stdcall;
  530.   end;
  531.  
  532. { IContextMenu2 (IContextMenu with one new member) }
  533. { IContextMenu2.HandleMenuMsg }
  534.  
  535. {  This function is called, if the client of IContextMenu is aware of }
  536. { IContextMenu2 interface and receives one of following messages while }
  537. { it is calling TrackPopupMenu (in the window proc of hwndOwner): }
  538. {      WM_INITPOPUP, WM_DRAWITEM and WM_MEASUREITEM }
  539. {  The callee may handle these messages to draw owner draw menuitems. }
  540.  
  541.   {$EXTERNALSYM IContextMenu2}
  542.   IContextMenu2 = interface(IContextMenu)
  543.     [SID_IContextMenu2]
  544.     function HandleMenuMsg(uMsg: UINT): HResult; stdcall;
  545.   end;
  546.  
  547. { Interface: IShellExtInit }
  548.  
  549. { The IShellExtInit interface is used by the explorer to initialize shell
  550.   extension objects. The explorer (1) calls CoCreateInstance (or equivalent)
  551.   with the registered CLSID and IID_IShellExtInit, (2) calls its Initialize
  552.   member, then (3) calls its QueryInterface to a particular interface (such
  553.   as IContextMenu or IPropSheetExt and (4) performs the rest of operation. }
  554.  
  555. { [Member functions] }
  556.  
  557. { IShellExtInit.Initialize }
  558.  
  559. { This member function is called when the explorer is initializing either
  560.   context menu extension, property sheet extension or non-default drag-drop
  561.   extension.
  562.  
  563.   Parameters: (context menu or property sheet extension)
  564.    pidlFolder -- Specifies the parent folder
  565.    lpdobj -- Spefifies the set of items selected in that folder.
  566.    hkeyProgID -- Specifies the type of the focused item in the selection.
  567.  
  568.   Parameters: (non-default drag-and-drop extension)
  569.    pidlFolder -- Specifies the target (destination) folder
  570.    lpdobj -- Specifies the items that are dropped (see the description
  571.     about shell's clipboard below for clipboard formats).
  572.    hkeyProgID -- Specifies the folder type. }
  573.  
  574. type
  575.   {$EXTERNALSYM IShellExtInit}
  576.   IShellExtInit = interface(IUnknown)
  577.     [SID_IShellExtInit]
  578.     function Initialize(pidlFolder: PItemIDList; lpdobj: IDataObject;
  579.       hKeyProgID: HKEY): HResult; stdcall;
  580.   end;
  581.  
  582. {=========================================================================== }
  583.  
  584. { Interface: IShellPropSheetExt }
  585.  
  586. { The explorer uses the IShellPropSheetExt to allow property sheet
  587.   extensions or control panel extensions to add additional property
  588.   sheet pages. }
  589.  
  590. { [Member functions] }
  591.  
  592. { IShellPropSheetExt.AddPages }
  593.  
  594. { The explorer calls this member function when it finds a registered
  595.   property sheet extension for a particular type of object. For each
  596.   additional page, the extension creates a page object by calling
  597.   CreatePropertySheetPage API and calls lpfnAddPage.
  598.  
  599.    Parameters:
  600.     lpfnAddPage -- Specifies the callback function.
  601.     lParam -- Specifies the opaque handle to be passed to the callback function. }
  602.  
  603.  
  604. { IShellPropSheetExt.ReplacePage }
  605.  
  606. { The explorer never calls this member of property sheet extensions. The
  607.   explorer calls this member of control panel extensions, so that they
  608.   can replace some of default control panel pages (such as a page of
  609.   mouse control panel).
  610.  
  611.    Parameters:
  612.     uPageID -- Specifies the page to be replaced.
  613.     lpfnReplace Specifies the callback function.
  614.     lParam -- Specifies the opaque handle to be passed to the callback function. }
  615.  
  616. type
  617.   {$EXTERNALSYM IShellPropSheetExt}
  618.   IShellPropSheetExt = interface(IUnknown)
  619.     [SID_IShellPropSheetExt]
  620.     function AddPages(lpfnAddPage: TFNAddPropSheetPage; lParam: LPARAM): HResult; stdcall;
  621.     function ReplacePage(uPageID: UINT; lpfnReplaceWith: TFNAddPropSheetPage;
  622.       lParam: LPARAM): HResult; stdcall;
  623.   end;
  624.  
  625. { IPersistFolder Interface }
  626. {  The IPersistFolder interface is used by the file system implementation of }
  627. { IShellFolder::BindToObject when it is initializing a shell folder object. }
  628.  
  629. { IPersistFolder::Initialize }
  630. {  This member function is called when the explorer is initializing a }
  631. { shell folder object. }
  632. {  Parameters: }
  633. {   pidl -- Specifies the absolute location of the folder. }
  634.  
  635.   {$EXTERNALSYM IPersistFolder}
  636.   IPersistFolder = interface(IPersist)
  637.     [SID_IPersistFolder]
  638.     function Initialize(pidl: PItemIDList): HResult; stdcall;
  639.   end;
  640.  
  641. { IExtractIcon interface }
  642.  
  643. { This interface is used in two different places in the shell.
  644.  
  645.   Case-1: Icons of sub-folders for the scope-pane of the explorer.
  646.  
  647.    It is used by the explorer to get the 'icon location' of
  648.   sub-folders from each shell folders. When the user expands a folder
  649.   in the scope pane of the explorer, the explorer does following:
  650.    (1) binds to the folder (gets IShellFolder),
  651.    (2) enumerates its sub-folders by calling its EnumObjects member,
  652.    (3) calls its GetUIObjectOf member to get IExtractIcon interface
  653.       for each sub-folders.
  654.    In this case, the explorer uses only IExtractIcon.GetIconLocation
  655.   member to get the location of the appropriate icon. An icon location
  656.   always consists of a file name (typically DLL or EXE) and either an icon
  657.   resource or an icon index.
  658.  
  659.  
  660.   Case-2: Extracting an icon image from a file
  661.  
  662.    It is used by the shell when it extracts an icon image
  663.   from a file. When the shell is extracting an icon from a file,
  664.   it does following:
  665.    (1) creates the icon extraction handler object (by getting its CLSID
  666.       under the beginProgIDend\shell\ExtractIconHanler key and calling
  667.       CoCreateInstance requesting for IExtractIcon interface).
  668.    (2) Calls IExtractIcon.GetIconLocation.
  669.    (3) Then, calls IExtractIcon.Extract with the location/index pair.
  670.    (4) If (3) returns NOERROR, it uses the returned icon.
  671.    (5) Otherwise, it recursively calls this logic with new location
  672.       assuming that the location string contains a fully qualified path name.
  673.  
  674.    From extension programmer's point of view, there are only two cases
  675.   where they provide implementations of IExtractIcon:
  676.    Case-1) providing explorer extensions (i.e., IShellFolder).
  677.    Case-2) providing per-instance icons for some types of files.
  678.  
  679.   Because Case-1 is described above, we'll explain only Case-2 here.
  680.  
  681.   When the shell is about display an icon for a file, it does following:
  682.    (1) Finds its ProgID and ClassID.
  683.    (2) If the file has a ClassID, it gets the icon location string from the
  684.      'DefaultIcon' key under it. The string indicates either per-class
  685.      icon (e.g., 'FOOBAR.DLL,2') or per-instance icon (e.g., '%1,1').
  686.    (3) If a per-instance icon is specified, the shell creates an icon
  687.      extraction handler object for it, and extracts the icon from it
  688.      (which is described above).
  689.  
  690.    It is important to note that the shell calls IExtractIcon.GetIconLocation
  691.   first, then calls IExtractIcon.Extract. Most application programs
  692.   that support per-instance icons will probably store an icon location
  693.   (DLL/EXE name and index/id) rather than an icon image in each file.
  694.   In those cases, a programmer needs to implement only the GetIconLocation
  695.   member and it Extract member simply returns S_FALSE. They need to
  696.   implement Extract member only if they decided to store the icon images
  697.   within files themselved or some other database (which is very rare). }
  698.  
  699. { [Member functions] }
  700.  
  701. { IExtractIcon.GetIconLocation }
  702.  
  703. { This function returns an icon location.
  704.  
  705.   Parameters:
  706.    uFlags     [in]  -- Specifies if it is opened or not (GIL_OPENICON or 0)
  707.    szIconFile [out] -- Specifies the string buffer buffer for a location name.
  708.    cchMax     [in]  -- Specifies the size of szIconFile (almost always MAX_PATH)
  709.    piIndex    [out] -- Sepcifies the address of UINT for the index.
  710.    pwFlags    [out] -- Returns GIL_* flags
  711.   Returns:
  712.    NOERROR, if it returns a valid location; S_FALSE, if the shell use a
  713.    default icon.
  714.  
  715.   Notes: The location may or may not be a path to a file. The caller can
  716.    not assume anything unless the subsequent Extract member call returns
  717.    S_FALSE.
  718.  
  719.    if the returned location is not a path to a file, GIL_NOTFILENAME should
  720.    be set in the returned flags. }
  721.  
  722. { IExtractIcon.Extract }
  723.  
  724. { This function extracts an icon image from a specified file.
  725.  
  726.   Parameters:
  727.    pszFile [in] -- Specifies the icon location (typically a path to a file).
  728.    nIconIndex [in] -- Specifies the icon index.
  729.    phiconLarge [out] -- Specifies the HICON variable for large icon.
  730.    phiconSmall [out] -- Specifies the HICON variable for small icon.
  731.    nIconSize [in] -- Specifies the size icon required (size of large icon)
  732.              LOWORD is the requested large icon size
  733.              HIWORD is the requested small icon size
  734.   Returns:
  735.    NOERROR, if it extracted the from the file.
  736.    S_FALSE, if the caller should extract from the file specified in the
  737.        location. }
  738.  
  739. const
  740.   {$EXTERNALSYM GIL_OPENICON}
  741.   GIL_OPENICON         = $0001;      { allows containers to specify an "open" look }
  742.   {$EXTERNALSYM GIL_FORSHELL}
  743.   GIL_FORSHELL         = $0002;      { icon is to be displayed in a ShellFolder }
  744.   {$EXTERNALSYM GIL_ASYNC}
  745.   GIL_ASYNC            = $0020;      { this is an async extract, return E_ASYNC }
  746.  
  747. { GetIconLocation() return flags }
  748.  
  749.   {$EXTERNALSYM GIL_SIMULATEDOC}
  750.   GIL_SIMULATEDOC      = $0001;      { simulate this document icon for this }
  751.   {$EXTERNALSYM GIL_PERINSTANCE}
  752.   GIL_PERINSTANCE      = $0002;      { icons from this class are per instance (each file has its own) }
  753.   {$EXTERNALSYM GIL_PERCLASS}
  754.   GIL_PERCLASS         = $0004;      { icons from this class per class (shared for all files of this type) }
  755.   {$EXTERNALSYM GIL_NOTFILENAME}
  756.   GIL_NOTFILENAME      = $0008;      { location is not a filename, must call ::ExtractIcon }
  757.   {$EXTERNALSYM GIL_DONTCACHE}
  758.   GIL_DONTCACHE        = $0010;      { this icon should not be cached }
  759.  
  760. type
  761.   {$EXTERNALSYM IExtractIconA}
  762.   IExtractIconA = interface(IUnknown)
  763.     [SID_IExtractIconA]
  764.     function GetIconLocation(uFlags: UINT; szIconFile: PAnsiChar; cchMax: UINT;
  765.       out piIndex: Integer; out pwFlags: UINT): HResult; stdcall;
  766.     function Extract(pszFile: PAnsiChar; nIconIndex: UINT;
  767.       out phiconLarge, phiconSmall: HICON; nIconSize: UINT): HResult; stdcall;
  768.   end;
  769.   {$EXTERNALSYM IExtractIconW}
  770.   IExtractIconW = interface(IUnknown)
  771.     [SID_IExtractIconW]
  772.     function GetIconLocation(uFlags: UINT; szIconFile: PWideChar; cchMax: UINT;
  773.       out piIndex: Integer; out pwFlags: UINT): HResult; stdcall;
  774.     function Extract(pszFile: PWideChar; nIconIndex: UINT;
  775.       out phiconLarge, phiconSmall: HICON; nIconSize: UINT): HResult; stdcall;
  776.   end;
  777.   {$EXTERNALSYM IExtractIcon}
  778.   IExtractIcon = IExtractIconA;
  779.  
  780.  
  781. { IShellIcon Interface }
  782. { used to get a icon index for a IShellFolder object. }
  783.  
  784. { this interface can be implemented by a IShellFolder, as a quick way to }
  785. { return the icon for a object in the folder. }
  786.  
  787. { a instance of this interface is only created once for the folder, unlike }
  788. { IExtractIcon witch is created once for each object. }
  789.  
  790. { if a ShellFolder does not implement this interface, the standard }
  791. { GetUIObject(....IExtractIcon) method will be used to get a icon }
  792. { for all objects. }
  793.  
  794. { the following standard imagelist indexs can be returned: }
  795.  
  796. {      0   document (blank page) (not associated) }
  797. {      1   document (with stuff on the page) }
  798. {      2   application (exe, com, bat) }
  799. {      3   folder (plain) }
  800. {      4   folder (open) }
  801.  
  802. { IShellIcon.GetIconOf(pidl, flags, lpIconIndex) }
  803.  
  804. {      pidl            object to get icon for. }
  805. {      flags           GIL_* input flags (GIL_OPEN, ...) }
  806. {      lpIconIndex     place to return icon index. }
  807.  
  808. {  returns: }
  809. {      NOERROR, if lpIconIndex contains the correct system imagelist index. }
  810. {      S_FALSE, if unable to get icon for this object, go through }
  811. {               GetUIObject, IExtractIcon, methods. }
  812.  
  813.   {$EXTERNALSYM IShellIcon}
  814.   IShellIcon = interface(IUnknown)
  815.     [SID_IShellIcon]
  816.     function GetIconOf(pidl: PItemIDList; flags: UINT;
  817.       out IconIndex: Integer): HResult; stdcall;
  818.   end;
  819.  
  820.  
  821. { IShellLink Interface }
  822. const
  823. { IShellLink.Resolve fFlags }
  824.  
  825.   {$EXTERNALSYM SLR_NO_UI}
  826.   SLR_NO_UI           = $0001;
  827.   {$EXTERNALSYM SLR_ANY_MATCH}
  828.   SLR_ANY_MATCH       = $0002;
  829.   {$EXTERNALSYM SLR_UPDATE}
  830.   SLR_UPDATE          = $0004;
  831.  
  832. { IShellLink.GetPath fFlags }
  833.  
  834.   {$EXTERNALSYM SLGP_SHORTPATH}
  835.   SLGP_SHORTPATH      = $0001;
  836.   {$EXTERNALSYM SLGP_UNCPRIORITY}
  837.   SLGP_UNCPRIORITY    = $0002;
  838.  
  839. type
  840.   {$EXTERNALSYM IShellLinkA}
  841.   IShellLinkA = interface(IUnknown) { sl }
  842.     [SID_IShellLinkA]
  843.     function GetPath(pszFile: PAnsiChar; cchMaxPath: Integer;
  844.       var pfd: TWin32FindData; fFlags: DWORD): HResult; stdcall;
  845.     function GetIDList(var ppidl: PItemIDList): HResult; stdcall;
  846.     function SetIDList(pidl: PItemIDList): HResult; stdcall;
  847.     function GetDescription(pszName: PAnsiChar; cchMaxName: Integer): HResult; stdcall;
  848.     function SetDescription(pszName: PAnsiChar): HResult; stdcall;
  849.     function GetWorkingDirectory(pszDir: PAnsiChar; cchMaxPath: Integer): HResult; stdcall;
  850.     function SetWorkingDirectory(pszDir: PAnsiChar): HResult; stdcall;
  851.     function GetArguments(pszArgs: PAnsiChar; cchMaxPath: Integer): HResult; stdcall;
  852.     function SetArguments(pszArgs: PAnsiChar): HResult; stdcall;
  853.     function GetHotkey(var pwHotkey: Word): HResult; stdcall;
  854.     function SetHotkey(wHotkey: Word): HResult; stdcall;
  855.     function GetShowCmd(out piShowCmd: Integer): HResult; stdcall;
  856.     function SetShowCmd(iShowCmd: Integer): HResult; stdcall;
  857.     function GetIconLocation(pszIconPath: PAnsiChar; cchIconPath: Integer;
  858.       out piIcon: Integer): HResult; stdcall;
  859.     function SetIconLocation(pszIconPath: PAnsiChar; iIcon: Integer): HResult; stdcall;
  860.     function SetRelativePath(pszPathRel: PAnsiChar; dwReserved: DWORD): HResult; stdcall;
  861.     function Resolve(Wnd: HWND; fFlags: DWORD): HResult; stdcall;
  862.     function SetPath(pszFile: PAnsiChar): HResult; stdcall;
  863.   end;
  864.   {$EXTERNALSYM IShellLinkW}
  865.   IShellLinkW = interface(IUnknown) { sl }
  866.     [SID_IShellLinkW]
  867.     function GetPath(pszFile: PWideChar; cchMaxPath: Integer;
  868.       var pfd: TWin32FindData; fFlags: DWORD): HResult; stdcall;
  869.     function GetIDList(var ppidl: PItemIDList): HResult; stdcall;
  870.     function SetIDList(pidl: PItemIDList): HResult; stdcall;
  871.     function GetDescription(pszName: PWideChar; cchMaxName: Integer): HResult; stdcall;
  872.     function SetDescription(pszName: PWideChar): HResult; stdcall;
  873.     function GetWorkingDirectory(pszDir: PWideChar; cchMaxPath: Integer): HResult; stdcall;
  874.     function SetWorkingDirectory(pszDir: PWideChar): HResult; stdcall;
  875.     function GetArguments(pszArgs: PWideChar; cchMaxPath: Integer): HResult; stdcall;
  876.     function SetArguments(pszArgs: PWideChar): HResult; stdcall;
  877.     function GetHotkey(var pwHotkey: Word): HResult; stdcall;
  878.     function SetHotkey(wHotkey: Word): HResult; stdcall;
  879.     function GetShowCmd(out piShowCmd: Integer): HResult; stdcall;
  880.     function SetShowCmd(iShowCmd: Integer): HResult; stdcall;
  881.     function GetIconLocation(pszIconPath: PWideChar; cchIconPath: Integer;
  882.       out piIcon: Integer): HResult; stdcall;
  883.     function SetIconLocation(pszIconPath: PWideChar; iIcon: Integer): HResult; stdcall;
  884.     function SetRelativePath(pszPathRel: PWideChar; dwReserved: DWORD): HResult; stdcall;
  885.     function Resolve(Wnd: HWND; fFlags: DWORD): HResult; stdcall;
  886.     function SetPath(pszFile: PWideChar): HResult; stdcall;
  887.   end;
  888.   {$EXTERNALSYM IShellLink}
  889.   IShellLink = IShellLinkA;
  890.  
  891. { IShellExecuteHook Interface }
  892.  
  893.   {$EXTERNALSYM IShellExecuteHookA}
  894.   IShellExecuteHookA = interface(IUnknown) { sl }
  895.     [SID_IShellExecuteHookA]
  896.     function Execute(var ShellExecuteInfo: TShellExecuteInfo): HResult; stdcall;
  897.   end;
  898.   {$EXTERNALSYM IShellExecuteHookW}
  899.   IShellExecuteHookW = interface(IUnknown) { sl }
  900.     [SID_IShellExecuteHookW]
  901.     function Execute(var ShellExecuteInfo: TShellExecuteInfo): HResult; stdcall;
  902.   end;
  903.   {$EXTERNALSYM IShellExecuteHook}
  904.   IShellExecuteHook = IShellExecuteHookA;
  905.  
  906. { INewShortcutHook Interface }
  907.  
  908.   {$EXTERNALSYM INewShortcutHookA}
  909.   INewShortcutHookA = interface(IUnknown) { sl }
  910.     [SID_INewShortcutHookA]
  911.     function SetReferent(pcszReferent: PAnsiChar; Wnd: HWND): HResult; stdcall;
  912.     function GetReferent(pcszReferent: PAnsiChar; cchReferent: Integer): HResult; stdcall;
  913.     function SetFolder(pcszFolder: PAnsiChar; Wnd: HWND): HResult; stdcall;
  914.     function GetFolder(pcszFolder: PAnsiChar; cchFolder: Integer): HResult; stdcall;
  915.     function GetName(pcszName: PAnsiChar; cchName: Integer): HResult; stdcall;
  916.     function GetExtension(pcszExtension: PAnsiChar; cchExtension: Integer): HResult; stdcall;
  917.   end;
  918.   {$EXTERNALSYM INewShortcutHookW}
  919.   INewShortcutHookW = interface(IUnknown) { sl }
  920.     [SID_INewShortcutHookW]
  921.     function SetReferent(pcszReferent: PWideChar; Wnd: HWND): HResult; stdcall;
  922.     function GetReferent(pcszReferent: PWideChar; cchReferent: Integer): HResult; stdcall;
  923.     function SetFolder(pcszFolder: PWideChar; Wnd: HWND): HResult; stdcall;
  924.     function GetFolder(pcszFolder: PWideChar; cchFolder: Integer): HResult; stdcall;
  925.     function GetName(pcszName: PWideChar; cchName: Integer): HResult; stdcall;
  926.     function GetExtension(pcszExtension: PWideChar; cchExtension: Integer): HResult; stdcall;
  927.   end;
  928.   {$EXTERNALSYM INewShortcutHook}
  929.   INewShortcutHook = INewShortcutHookA;
  930.  
  931. { ICopyHook Interface }
  932.  
  933. { The copy hook is called whenever file system directories are
  934.   copy/moved/deleted/renamed via the shell.  It is also called by the shell
  935.   on changes of status of printers.
  936.   Clients register their id under STRREG_SHEX_COPYHOOK for file system hooks
  937.   and STRREG_SHEx_PRNCOPYHOOK for printer hooks.
  938.   the CopyCallback is called prior to the action, so the hook has the chance
  939.   to allow, deny or cancel the operation by returning the falues:
  940.      IDYES  -  means allow the operation
  941.      IDNO   -  means disallow the operation on this file, but continue with
  942.           any other operations (eg. batch copy)
  943.      IDCANCEL - means disallow the current operation and cancel any pending
  944.           operations
  945.    arguments to the CopyCallback
  946.       hwnd - window to use for any UI
  947.       wFunc - what operation is being done
  948.       wFlags - and flags (FOF_*) set in the initial call to the file operation
  949.       pszSrcFile - name of the source file
  950.       dwSrcAttribs - file attributes of the source file
  951.       pszDestFile - name of the destiation file (for move and renames)
  952.       dwDestAttribs - file attributes of the destination file }
  953.  
  954. type
  955.   {$EXTERNALSYM ICopyHookA}
  956.   ICopyHookA = interface(IUnknown) { sl }
  957.     [SID_IShellCopyHookA]
  958.     function CopyCallback(Wnd: HWND; wFunc, wFlags: UINT; pszSrcFile: PAnsiChar;
  959.       dwSrcAttribs: DWORD; pszDestFile: PAnsiChar; dwDestAttribs: DWORD): UINT; stdcall;
  960.   end;
  961.   {$EXTERNALSYM ICopyHookW}
  962.   ICopyHookW = interface(IUnknown) { sl }
  963.     [SID_IShellCopyHookW]
  964.     function CopyCallback(Wnd: HWND; wFunc, wFlags: UINT; pszSrcFile: PWideChar;
  965.       dwSrcAttribs: DWORD; pszDestFile: PWideChar; dwDestAttribs: DWORD): UINT; stdcall;
  966.   end;
  967.   {$EXTERNALSYM ICopyHook}
  968.   ICopyHook = ICopyHookA;
  969.  
  970. { IFileViewerSite Interface }
  971.  
  972. type
  973.   {$EXTERNALSYM IFileViewerSite}
  974.   IFileViewerSite = interface(IUnknown)
  975.     [SID_IFileViewerSite]
  976.     function SetPinnedWindow(Wnd: HWND): HResult; stdcall;
  977.     function GetPinnedWindow(var Wnd: HWND): HResult; stdcall;
  978.   end;
  979.  
  980. { IFileViewer Interface }
  981.  
  982. { Implemented in a FileViewer component object.  Used to tell a
  983.   FileViewer to PrintTo or to view, the latter happening though
  984.   ShowInitialize and Show.  The filename is always given to the
  985.   viewer through IPersistFile. }
  986.  
  987. type
  988.   // !!! unnamed struct
  989.   PFVShowInfo = ^TFVShowInfo;
  990.   TFVShowInfo = packed record
  991.     { Stuff passed into viewer (in) }
  992.     cbSize: DWORD;           { Size of structure for future expansion... }
  993.     hwndOwner: HWND;         { who is the owner window. }
  994.     iShow: Integer;          { The show command }
  995.  
  996.     { Passed in and updated  (in/Out) }
  997.     dwFlags: DWORD;          { flags }
  998.     rect: TRECT;             { Where to create the window may have defaults }
  999.     punkRel: IUNKNOWN;       { Relese this interface when window is visible }
  1000.  
  1001.     { Stuff that might be returned from viewer (out) }
  1002.     strNewFile: array[0..MAX_PATH-1] of TOleChar;   { New File to view. }
  1003.   end;
  1004.  
  1005. const
  1006. { Define File View Show Info Flags. }
  1007.  
  1008.   {$EXTERNALSYM FVSIF_RECT}
  1009.   FVSIF_RECT      = $00000001;      { The rect variable has valid data. }
  1010.   {$EXTERNALSYM FVSIF_PINNED}
  1011.   FVSIF_PINNED    = $00000002;      { We should Initialize pinned }
  1012.  
  1013.   {$EXTERNALSYM FVSIF_NEWFAILED}
  1014.   FVSIF_NEWFAILED = $08000000;      { The new file passed back failed
  1015.                        to be viewed. }
  1016.  
  1017.   {$EXTERNALSYM FVSIF_NEWFILE}
  1018.   FVSIF_NEWFILE   = $80000000;      { A new file to view has been returned }
  1019.   {$EXTERNALSYM FVSIF_CANVIEWIT}
  1020.   FVSIF_CANVIEWIT = $40000000;      { The viewer can view it. }
  1021.  
  1022. type
  1023.   {$EXTERNALSYM IFileViewerA}
  1024.   IFileViewerA = interface(IUnknown)
  1025.     [SID_IFileViewerA]
  1026.     function ShowInitialize(fsi: IFileViewerSite): HResult; stdcall;
  1027.     function Show(var pvsi: TFVShowInfo): HResult; stdcall;
  1028.     function PrintTo(pszDriver: PAnsiChar; fSuppressUI: BOOL): HResult; stdcall;
  1029.   end;
  1030.   {$EXTERNALSYM IFileViewerW}
  1031.   IFileViewerW = interface(IUnknown)
  1032.     [SID_IFileViewerW]
  1033.     function ShowInitialize(fsi: IFileViewerSite): HResult; stdcall;
  1034.     function Show(var pvsi: TFVShowInfo): HResult; stdcall;
  1035.     function PrintTo(pszDriver: PWideChar; fSuppressUI: BOOL): HResult; stdcall;
  1036.   end;
  1037.   {$EXTERNALSYM IFileViewer}
  1038.   IFileViewer = IFileViewerA;
  1039.  
  1040. { CommandTarget ids. for shell doc view wedge }
  1041.  
  1042.   {$EXTERNALSYM TSHDVIDEnums}
  1043.   TSHDVIDEnums = (
  1044.     SHDVID_SETPROGRESSPOS,
  1045.     SHDVID_SETPROGRESSRANGE,
  1046.     SHDVID_SETSTATUSTEXT,        { variantIn  bstr }
  1047.     SHDVID_REFRESH,
  1048.     SHDVID_STOP,
  1049.     SHDVID_UPDATECOMMANDS, { / this forces a re-querystatus of the command targets. }
  1050.                { / the arg in can specify a specific one to update or NIL for evrything }
  1051.     SHDVID_SETTITLE,            { variantIn bstr }
  1052.     SHDVID_FINALTITLEAVAIL,     { variantIn bstr - sent after final SETTITLE is sent }
  1053.     SHDVID_STARTLOAD,           { NIL for everything }
  1054.     SHDVID_STOPLOAD,            { NIL for everything }
  1055.     SHDVID_CCALLBACK,           { callback to arbitrary C func }
  1056.     SHDVID_MENUEXEC,            { do menu command }
  1057.     SHDVID_MENUQS               { query menu commands }
  1058.   );
  1059.  
  1060. { IShellBrowser/IShellView/IShellFolder interface }
  1061.  
  1062. {  These three interfaces are used when the shell communicates with }
  1063. { name space extensions. The shell (explorer) provides IShellBrowser }
  1064. { interface, and extensions implements IShellFolder and IShellView }
  1065. { interfaces. }
  1066.  
  1067. { ========================================================================== }
  1068.  
  1069.  
  1070. { -------------------------------------------------------------------------- }
  1071.  
  1072. { Command/menuitem IDs }
  1073.  
  1074. {  The explorer dispatches WM_COMMAND messages based on the range of }
  1075. { command/menuitem IDs. All the IDs of menuitems that the view (right }
  1076. { pane) inserts must be in FCIDM_SHVIEWFIRST/LAST (otherwise, the explorer }
  1077. { won't dispatch them). The view should not deal with any menuitems }
  1078. { in FCIDM_BROWSERFIRST/LAST (otherwise, it won't work with the future }
  1079. { version of the shell). }
  1080.  
  1081. {  FCIDM_SHVIEWFIRST/LAST      for the right pane (IShellView) }
  1082. {  FCIDM_BROWSERFIRST/LAST     for the explorer frame (IShellBrowser) }
  1083. {  FCIDM_GLOBAL/LAST           for the explorer's submenu IDs }
  1084.  
  1085. const
  1086.   {$EXTERNALSYM FCIDM_SHVIEWFIRST}
  1087.   FCIDM_SHVIEWFIRST               = $0000;
  1088.   {$EXTERNALSYM FCIDM_SHVIEWLAST}
  1089.   FCIDM_SHVIEWLAST                = $7fff;
  1090.   {$EXTERNALSYM FCIDM_BROWSERFIRST}
  1091.   FCIDM_BROWSERFIRST              = $a000;
  1092.   {$EXTERNALSYM FCIDM_BROWSERLAST}
  1093.   FCIDM_BROWSERLAST               = $bf00;
  1094.   {$EXTERNALSYM FCIDM_GLOBALFIRST}
  1095.   FCIDM_GLOBALFIRST               = $8000;
  1096.   {$EXTERNALSYM FCIDM_GLOBALLAST}
  1097.   FCIDM_GLOBALLAST                = $9fff;
  1098.  
  1099.  
  1100. { Global submenu IDs and separator IDs }
  1101.  
  1102.   {$EXTERNALSYM FCIDM_MENU_FILE}
  1103.   FCIDM_MENU_FILE                 = FCIDM_GLOBALFIRST+$0000;
  1104.   {$EXTERNALSYM FCIDM_MENU_EDIT}
  1105.   FCIDM_MENU_EDIT                 = FCIDM_GLOBALFIRST+$0040;
  1106.   {$EXTERNALSYM FCIDM_MENU_VIEW}
  1107.   FCIDM_MENU_VIEW                 = FCIDM_GLOBALFIRST+$0080;
  1108.   {$EXTERNALSYM FCIDM_MENU_VIEW_SEP_OPTIONS}
  1109.   FCIDM_MENU_VIEW_SEP_OPTIONS     = FCIDM_GLOBALFIRST+$0081;
  1110.   {$EXTERNALSYM FCIDM_MENU_TOOLS}
  1111.   FCIDM_MENU_TOOLS                = FCIDM_GLOBALFIRST+$00c0;
  1112.   {$EXTERNALSYM FCIDM_MENU_TOOLS_SEP_GOTO}
  1113.   FCIDM_MENU_TOOLS_SEP_GOTO       = FCIDM_GLOBALFIRST+$00c1;
  1114.   {$EXTERNALSYM FCIDM_MENU_HELP}
  1115.   FCIDM_MENU_HELP                 = FCIDM_GLOBALFIRST+$0100;
  1116.   {$EXTERNALSYM FCIDM_MENU_FIND}
  1117.   FCIDM_MENU_FIND                 = FCIDM_GLOBALFIRST+$0140;
  1118.   {$EXTERNALSYM FCIDM_MENU_EXPLORE}
  1119.   FCIDM_MENU_EXPLORE              = FCIDM_GLOBALFIRST+$0150;
  1120.   {$EXTERNALSYM FCIDM_MENU_FAVORITES}
  1121.   FCIDM_MENU_FAVORITES            = FCIDM_GLOBALFIRST+$0170;
  1122.  
  1123. { -------------------------------------------------------------------------- }
  1124. { control IDs known to the view }
  1125. { -------------------------------------------------------------------------- }
  1126.  
  1127.   {$EXTERNALSYM FCIDM_TOOLBAR}
  1128.   FCIDM_TOOLBAR          = FCIDM_BROWSERFIRST + 0;
  1129.   {$EXTERNALSYM FCIDM_STATUS}
  1130.   FCIDM_STATUS           = FCIDM_BROWSERFIRST + 1;
  1131.  
  1132.  
  1133. { -------------------------------------------------------------------------- }
  1134.  
  1135. { FOLDERSETTINGS }
  1136.  
  1137. {  FOLDERSETTINGS is a data structure that explorer passes from one folder }
  1138. { view to another, when the user is browsing. It calls ISV::GetCurrentInfo }
  1139. { member to get the current settings and pass it to ISV::CreateViewWindow }
  1140. { to allow the next folder view "inherit" it. These settings assumes a }
  1141. { particular UI (which the shell's folder view has), and shell extensions }
  1142. { may or may not use those settings. }
  1143.  
  1144. { -------------------------------------------------------------------------- }
  1145.  
  1146. { NB Bitfields. }
  1147. { FWF_DESKTOP implies FWF_TRANSPARENT/NOCLIENTEDGE/NOSCROLL }
  1148. const
  1149.   {$EXTERNALSYM FWF_AUTOARRANGE}
  1150.   FWF_AUTOARRANGE = $0001;
  1151.   {$EXTERNALSYM FWF_ABBREVIATEDNAMES}
  1152.   FWF_ABBREVIATEDNAMES = $0002;
  1153.   {$EXTERNALSYM FWF_SNAPTOGRID}
  1154.   FWF_SNAPTOGRID = $0004;
  1155.   {$EXTERNALSYM FWF_OWNERDATA}
  1156.   FWF_OWNERDATA = $0008;
  1157.   {$EXTERNALSYM FWF_BESTFITWINDOW}
  1158.   FWF_BESTFITWINDOW = $0010;
  1159.   {$EXTERNALSYM FWF_DESKTOP}
  1160.   FWF_DESKTOP = $0020;
  1161.   {$EXTERNALSYM FWF_SINGLESEL}
  1162.   FWF_SINGLESEL = $0040;
  1163.   {$EXTERNALSYM FWF_NOSUBFOLDERS}
  1164.   FWF_NOSUBFOLDERS = $0080;
  1165.   {$EXTERNALSYM FWF_TRANSPARENT}
  1166.   FWF_TRANSPARENT = $0100;
  1167.   {$EXTERNALSYM FWF_NOCLIENTEDGE}
  1168.   FWF_NOCLIENTEDGE = $0200;
  1169.   {$EXTERNALSYM FWF_NOSCROLL}
  1170.   FWF_NOSCROLL    = $0400;
  1171.   {$EXTERNALSYM FWF_ALIGNLEFT}
  1172.   FWF_ALIGNLEFT   = $0800;
  1173.   {$EXTERNALSYM FWF_SINGLECLICKACTIVATE}
  1174.   FWF_SINGLECLICKACTIVATE = $8000; { TEMPORARY -- NO UI FOR THIS }
  1175.  
  1176.   {$EXTERNALSYM FVM_ICON}
  1177.   FVM_ICON = 1;
  1178.   {$EXTERNALSYM FVM_SMALLICON}
  1179.   FVM_SMALLICON = 2;
  1180.   {$EXTERNALSYM FVM_LIST}
  1181.   FVM_LIST = 3;
  1182.   {$EXTERNALSYM FVM_DETAILS}
  1183.   FVM_DETAILS = 4;
  1184.  
  1185. type
  1186.   // !!! unnamed struct
  1187.   PFolderSettings = ^TFolderSettings;
  1188.   TFolderSettings = packed record
  1189.     ViewMode: UINT;      { View mode (FOLDERVIEWMODE values) }
  1190.     fFlags: UINT;        { View options (FOLDERFLAGS bits) }
  1191.   end;
  1192.  
  1193. { -------------------------------------------------------------------------- }
  1194.  
  1195. { Interface:   IShellBrowser }
  1196.  
  1197. {  IShellBrowser interface is the interface that is provided by the shell }
  1198. { explorer/folder frame window. When it creates the "contents pane" of }
  1199. { a shell folder (which provides IShellFolder interface), it calls its }
  1200. { CreateViewObject member function to create an IShellView object. Then, }
  1201. { it calls its CreateViewWindow member to create the "contents pane" }
  1202. { window. The pointer to the IShellBrowser interface is passed to }
  1203. { the IShellView object as a parameter to this CreateViewWindow member }
  1204. { function call. }
  1205.  
  1206. {    +--------------------------+  <-- Explorer window }
  1207. {    | [] Explorer              | }
  1208. {    |--------------------------+       IShellBrowser }
  1209. {    | File Edit View ..        | }
  1210. {    |--------------------------| }
  1211. {    |        |                 | }
  1212. {    |        |              <-------- Content pane }
  1213. {    |        |                 | }
  1214. {    |        |                 |       IShellView }
  1215. {    |        |                 | }
  1216. {    |        |                 | }
  1217. {    +--------------------------+ }
  1218.  
  1219.  
  1220.  
  1221. { [Member functions] }
  1222.  
  1223.  
  1224. { IShellBrowser.GetWindow(phwnd) }
  1225.  
  1226. {   Inherited from IOleWindow.GetWindow. }
  1227.  
  1228.  
  1229. { IShellBrowser.ContextSensitiveHelp(fEnterMode) }
  1230.  
  1231. {   Inherited from IOleWindow.ContextSensitiveHelp. }
  1232.  
  1233.  
  1234. { IShellBrowser.InsertMenusSB(hmenuShared, lpMenuWidths) }
  1235.  
  1236. {   Similar to the IOleInPlaceFrame.InsertMenus. The explorer will put }
  1237. {  "File" and "Edit" pulldown in the File menu group, "View" and "Tools" }
  1238. {  in the Container menu group and "Help" in the Window menu group. Each }
  1239. {  pulldown menu will have a uniqu ID, FCIDM_MENU_FILE/EDIT/VIEW/TOOLS/HELP. }
  1240. {  The view is allowed to insert menuitems into those sub-menus by those }
  1241. {  IDs must be between FCIDM_SHVIEWFIRST and FCIDM_SHVIEWLAST. }
  1242.  
  1243.  
  1244. { IShellBrowser.SetMenuSB(hmenuShared, holemenu, hwndActiveObject) }
  1245.  
  1246. {   Similar to the IOleInPlaceFrame.SetMenu. The explorer ignores the }
  1247. {  holemenu parameter (reserved for future enhancement)  and performs }
  1248. {  menu-dispatch based on the menuitem IDs (see the description above). }
  1249. {  It is important to note that the explorer will add different }
  1250. {  set of menuitems depending on whether the view has a focus or not. }
  1251. {  Therefore, it is very important to call ISB.OnViewWindowActivate }
  1252. {  whenever the view window (or its children) gets the focus. }
  1253.  
  1254.  
  1255. { IShellBrowser.RemoveMenusSB(hmenuShared) }
  1256.  
  1257. {   Same as the IOleInPlaceFrame.RemoveMenus. }
  1258.  
  1259.  
  1260. { IShellBrowser.SetStatusTextSB(lpszStatusText) }
  1261.  
  1262. {   Same as the IOleInPlaceFrame.SetStatusText. It is also possible to }
  1263. {  send messages directly to the status window via SendControlMsg. }
  1264.  
  1265.  
  1266. { IShellBrowser.EnableModelessSB(fEnable) }
  1267.  
  1268. {   Same as the IOleInPlaceFrame.EnableModeless. }
  1269.  
  1270. { IShellBrowser.TranslateAcceleratorSB(lpmsg, wID) }
  1271.  
  1272. {   Same as the IOleInPlaceFrame.TranslateAccelerator, but will be }
  1273. {  never called because we don't support EXEs (i.e., the explorer has }
  1274. {  the message loop). This member function is defined here for possible }
  1275. {  future enhancement. }
  1276.  
  1277.  
  1278. { IShellBrowser.BrowseObject(pidl, wFlags) }
  1279.  
  1280. {   The view calls this member to let shell explorer browse to another }
  1281. {  folder. The pidl and wFlags specifies the folder to be browsed. }
  1282.  
  1283. {  Following three flags specifies whether it creates another window or not. }
  1284. {   SBSP_SAMEBROWSER  -- Browse to another folder with the same window. }
  1285. {   SBSP_NEWBROWSER   -- Creates another window for the specified folder. }
  1286. {   SBSP_DEFBROWSER   -- Default behavior (respects the view option). }
  1287.  
  1288. {  Following three flags specifies open, explore, or default mode. These   . }
  1289. {  are ignored if SBSP_SAMEBROWSER or (SBSP_DEFBROWSER && (single window   . }
  1290. {  browser || explorer)).                                                  . }
  1291. {   SBSP_OPENMODE     -- Use a normal folder window }
  1292. {   SBSP_EXPLOREMODE  -- Use an explorer window }
  1293. {   SBSP_DEFMODE      -- Use the same as the current window }
  1294.  
  1295. {  Following three flags specifies the pidl. }
  1296. {   SBSP_ABSOLUTE -- pidl is an absolute pidl (relative from desktop) }
  1297. {   SBSP_RELATIVE -- pidl is relative from the current folder. }
  1298. {   SBSP_PARENT   -- Browse the parent folder (ignores the pidl) }
  1299.  
  1300.  
  1301. { IShellBrowser.GetViewStateStream(grfMode, ppstm) }
  1302.  
  1303. {   The browser returns an IStream interface as the storage for view }
  1304. {  specific state information. }
  1305.  
  1306. {   grfMode -- Specifies the read/write access (STGM_READ/WRITE/READWRITE) }
  1307. {   ppstm   -- Specifies the LPSTREAM variable to be filled. }
  1308.  
  1309.  
  1310. { IShellBrowser.GetControlWindow(id, phwnd) }
  1311.  
  1312. {   The shell view may call this member function to get the window handle }
  1313. {  of Explorer controls (toolbar or status winodw -- FCW_TOOLBAR or }
  1314. {  FCW_STATUS). }
  1315.  
  1316.  
  1317. { IShellBrowser.SendControlMsg(id, uMsg, wParam, lParam, pret) }
  1318.  
  1319. {   The shell view calls this member function to send control messages to }
  1320. {  one of Explorer controls (toolbar or status window -- FCW_TOOLBAR or }
  1321. {  FCW_STATUS). }
  1322.  
  1323.  
  1324. { IShellBrowser.QueryActiveShellView(IShellView * ppshv) }
  1325.  
  1326. {   This member returns currently activated (displayed) shellview object. }
  1327. {  A shellview never need to call this member function. }
  1328.  
  1329.  
  1330. { IShellBrowser.OnViewWindowActive(pshv) }
  1331.  
  1332. {   The shell view window calls this member function when the view window }
  1333. {  (or one of its children) got the focus. It MUST call this member before }
  1334. {  calling IShellBrowser.InsertMenus, because it will insert different }
  1335. {  set of menu items depending on whether the view has the focus or not. }
  1336.  
  1337.  
  1338. { IShellBrowser.SetToolbarItems(lpButtons, nButtons, uFlags) }
  1339.  
  1340. {   The view calls this function to add toolbar items to the exporer's }
  1341. {  toolbar. "lpButtons" and "nButtons" specifies the array of toolbar }
  1342. {  items. "uFlags" must be one of FCT_MERGE, FCT_CONFIGABLE, FCT_ADDTOEND. }
  1343.  
  1344. { ------------------------------------------------------------------------- }
  1345.  
  1346.  
  1347. { Values for wFlags parameter of ISB.BrowseObject() member. }
  1348. const
  1349.   {$EXTERNALSYM SBSP_DEFBROWSER}
  1350.   SBSP_DEFBROWSER      = $0000;
  1351.   {$EXTERNALSYM SBSP_SAMEBROWSER}
  1352.   SBSP_SAMEBROWSER     = $0001;
  1353.   {$EXTERNALSYM SBSP_NEWBROWSER}
  1354.   SBSP_NEWBROWSER      = $0002;
  1355.  
  1356.   {$EXTERNALSYM SBSP_DEFMODE}
  1357.   SBSP_DEFMODE         = $0000;
  1358.   {$EXTERNALSYM SBSP_OPENMODE}
  1359.   SBSP_OPENMODE        = $0010;
  1360.   {$EXTERNALSYM SBSP_EXPLOREMODE}
  1361.   SBSP_EXPLOREMODE     = $0020;
  1362.  
  1363.   {$EXTERNALSYM SBSP_ABSOLUTE}
  1364.   SBSP_ABSOLUTE        = $0000;
  1365.   {$EXTERNALSYM SBSP_RELATIVE}
  1366.   SBSP_RELATIVE        = $1000;
  1367.   {$EXTERNALSYM SBSP_PARENT}
  1368.   SBSP_PARENT          = $2000;
  1369.  
  1370.   {$EXTERNALSYM SBSP_INITIATEDBYHLINKFRAME}
  1371.   SBSP_INITIATEDBYHLINKFRAME            = $80000000;
  1372.   {$EXTERNALSYM SBSP_REDIRECT}
  1373.   SBSP_REDIRECT                         = $40000000;
  1374.  
  1375.  
  1376. { Values for id parameter of ISB.GetWindow/SendControlMsg members. }
  1377.  
  1378. { WARNING: }
  1379. {  Any shell extensions which sends messages to those control windows }
  1380. { might not work in the future version of windows. If you really need }
  1381. { to send messages to them, (1) don't assume that those control window }
  1382. { always exist (i.e. GetControlWindow may fail) and (2) verify the window }
  1383. { class of the window before sending any messages. }
  1384.  
  1385.   {$EXTERNALSYM FCW_STATUS}
  1386.   FCW_STATUS          = $0001;
  1387.   {$EXTERNALSYM FCW_TOOLBAR}
  1388.   FCW_TOOLBAR         = $0002;
  1389.   {$EXTERNALSYM FCW_TREE}
  1390.   FCW_TREE            = $0003;
  1391.  
  1392.  
  1393. { Values for uFlags paremeter of ISB.SetToolbarItems member. }
  1394.  
  1395.   {$EXTERNALSYM FCT_MERGE}
  1396.   FCT_MERGE           = $0001;
  1397.   {$EXTERNALSYM FCT_CONFIGABLE}
  1398.   FCT_CONFIGABLE      = $0002;
  1399.   {$EXTERNALSYM FCT_ADDTOEND}
  1400.   FCT_ADDTOEND        = $0004;
  1401.  
  1402. { ICommDlgBrowser.OnStateChange values }
  1403.  
  1404.   {$EXTERNALSYM CDBOSC_SETFOCUS}
  1405.   CDBOSC_SETFOCUS         = $00000000;
  1406.   {$EXTERNALSYM CDBOSC_KILLFOCUS}
  1407.   CDBOSC_KILLFOCUS        = $00000001;
  1408.   {$EXTERNALSYM CDBOSC_SELCHANGE}
  1409.   CDBOSC_SELCHANGE        = $00000002;
  1410.   {$EXTERNALSYM CDBOSC_RENAME}
  1411.   CDBOSC_RENAME           = $00000003;
  1412.  
  1413. { shellview select item flags }
  1414.  
  1415.   {$EXTERNALSYM SVSI_DESELECT}
  1416.   SVSI_DESELECT           = $0000;
  1417.   {$EXTERNALSYM SVSI_SELECT}
  1418.   SVSI_SELECT             = $0001;
  1419.   {$EXTERNALSYM SVSI_EDIT}
  1420.   SVSI_EDIT               = $0003;  { includes select }
  1421.   {$EXTERNALSYM SVSI_DESELECTOTHERS}
  1422.   SVSI_DESELECTOTHERS     = $0004;
  1423.   {$EXTERNALSYM SVSI_ENSUREVISIBLE}
  1424.   SVSI_ENSUREVISIBLE      = $0008;
  1425.   {$EXTERNALSYM SVSI_FOCUSED}
  1426.   SVSI_FOCUSED            = $0010;
  1427.  
  1428. { shellview get item object flags }
  1429.  
  1430.   {$EXTERNALSYM SVGIO_BACKGROUND}
  1431.   SVGIO_BACKGROUND        = $00000000;
  1432.   {$EXTERNALSYM SVGIO_SELECTION}
  1433.   SVGIO_SELECTION         = $00000001;
  1434.   {$EXTERNALSYM SVGIO_ALLVIEW}
  1435.   SVGIO_ALLVIEW           = $00000002;
  1436.  
  1437. type
  1438.   {$EXTERNALSYM HOLEMENU}
  1439.   HOLEMENU = HGLOBAL; // !!! should this be in ole2.pas?
  1440.  
  1441.   IShellView = interface;
  1442.  
  1443.   {$EXTERNALSYM IShellBrowser}
  1444.   IShellBrowser = interface(IOleWindow)
  1445.     [SID_IShellBrowser]
  1446.     function InsertMenusSB(hMenuShared: HMENU;
  1447.       out MenuWidths: TOleMenuGroupWidths): HResult; stdcall;
  1448.     function SetMenuSB(hMenuShared: HMENU;
  1449.       hOleMenuReserved: HOLEMENU): HResult; stdcall;
  1450.     function RemoveMenusSB(hMenuShared: HMENU): HResult; stdcall;
  1451.     function SetStatusTextSB(StatusText: POleStr): HResult; stdcall;
  1452.     function EnableModelessSB(Enable: BOOL): HResult; stdcall;
  1453.     function TranslateAcceleratorSB(Msg: PMsg; ID: Word): HResult; stdcall;
  1454.     function BrowseObject(pidl: PItemIDList; flags: UINT): HResult; stdcall;
  1455.     function GetViewStateStream(Mode: DWORD; out Stream: IStream): HResult; stdcall;
  1456.     function GetControlWindow(ID: UINT; out Wnd: HWND): HResult; stdcall;
  1457.     function SendControlMsg(ID, Msg: UINT; wParm: WPARAM; lParm: LPARAM;
  1458.       Result: LResult): HResult; stdcall;
  1459.     function QueryActiveShellView(var ShellView: IShellView): HResult; stdcall;
  1460.     function OnViewWindowActive(var ShellView: IShellView): HResult; stdcall;
  1461.     function SetToolbarItems(TBButton: PTBButton;
  1462.       nButtons, uFlags: UINT): HResult; stdcall;
  1463.   end;
  1464.  
  1465.   {$EXTERNALSYM TSBSCEnums}
  1466.   TSBSCEnums = (SBSC_HIDE, SBSC_SHOW, SBSC_TOGGLE, SBSC_QUERY);
  1467.  
  1468. { CommandTarget ids. }
  1469.   {$EXTERNALSYM TSBCMDIDEnums}
  1470.   TSBCMDIDEnums = (
  1471.     SBCMDID_ENABLESHOWTREE,
  1472.     SBCMDID_SHOWCONTROL,                { variant vt_i4 = loword = FCW_* hiword = SBSC_* }
  1473.     SBCMDID_CANCELNAVIGATION,           { cancel last navigation }
  1474.     SBCMDID_MAYSAVECHANGES,             { about to close and may save changes }
  1475.     SBCMDID_SETHLINKFRAME,              { variant vt_i4 = phlinkframe }
  1476.     SBCMDID_ENABLESTOP,                 { variant vt_bool = fEnable }
  1477.     SBCMDID_OPTIONS                     { the view.options page }
  1478.   );
  1479.  
  1480.  
  1481. { ICommDlgBrowser interface }
  1482.  
  1483. {  ICommDlgBrowser interface is the interface that is provided by the new }
  1484. { common dialog window to hook and modify the behavior of IShellView.  When }
  1485. { a default view is created, it queries its parent IShellBrowser for the }
  1486. { ICommDlgBrowser interface.  If supported, it calls out to that interface }
  1487. { in several cases that need to behave differently in a dialog. }
  1488.  
  1489. { Member functions: }
  1490.  
  1491. {  ICommDlgBrowser.OnDefaultCommand() }
  1492. {    Called when the user double-clicks in the view or presses Enter.  The }
  1493. {   browser should return S_OK if it processed the action itself, S_FALSE }
  1494. {   to let the view perform the default action. }
  1495.  
  1496. {  ICommDlgBrowser.OnStateChange(ULONG uChange) }
  1497. {    Called when some states in the view change.  'uChange' is one of the }
  1498. {   CDBOSC_* values.  This call is made after the state (selection, focus, }
  1499. {   etc) has changed.  There is no return value. }
  1500.  
  1501. {  ICommDlgBrowser.IncludeObject(LPCITEMIDLIST pidl) }
  1502. {    Called when the view is enumerating objects.  'pidl' is a relative }
  1503. {   IDLIST.  The browser should return S_OK to include the object in the }
  1504. {   view, S_FALSE to hide it }
  1505.  
  1506. { ------------------------------------------------------------------------- }
  1507.  
  1508.   {$EXTERNALSYM ICommDlgBrowser}
  1509.   ICommDlgBrowser = interface(IUnknown)
  1510.     [SID_ICommDlgBrowser]
  1511.     function OnDefaultCommand: HResult; stdcall;
  1512.     function OnStateChange(Change: ULONG): HResult; stdcall;
  1513.     function IncludeObject(pidl: PItemIDList): HResult; stdcall;
  1514.   end;
  1515.  
  1516.  
  1517. { Interface:   IShellView }
  1518.  
  1519. { IShellView.ContextSensitiveHelp(fEnterMode) }
  1520.  
  1521. {   Inherited from IOleWindow.ContextSensitiveHelp. }
  1522.  
  1523.  
  1524. { IShellView.TranslateAccelerator(lpmsg) }
  1525.  
  1526. {   Similar to IOleInPlaceActiveObject.TranlateAccelerator. The explorer }
  1527. {  calls this function BEFORE any other translation. Returning S_OK }
  1528. {  indicates that the message was translated (eaten) and should not be }
  1529. {  translated or dispatched by the explorer. }
  1530.  
  1531.  
  1532. { IShellView.EnableModeless(fEnable) }
  1533.  
  1534. {   Similar to IOleInPlaceActiveObject.EnableModeless. }
  1535.  
  1536.  
  1537. { IShellView.UIActivate(uState) }
  1538.  
  1539. {   The explorer calls this member function whenever the activation }
  1540. {  state of the view window is changed by a certain event that is }
  1541. {  NOT caused by the shell view itself. }
  1542.  
  1543. {   SVUIA_DEACTIVATE will be passed when the explorer is about to }
  1544. {  destroy the shell view window; the shell view is supposed to remove }
  1545. {  all the extended UIs (typically merged menu and modeless popup windows). }
  1546.  
  1547. {   SVUIA_ACTIVATE_NOFOCUS will be passsed when the shell view is losing }
  1548. {  the input focus or the shell view has been just created without the }
  1549. {  input focus; the shell view is supposed to set menuitems appropriate }
  1550. {  for non-focused state (no selection specific items should be added). }
  1551.  
  1552. {   SVUIA_ACTIVATE_FOCUS will be passed when the explorer has just }
  1553. {  created the view window with the input focus; the shell view is }
  1554. {  supposed to set menuitems appropriate for focused state. }
  1555.  
  1556. {   SVUIA_INPLACEACTIVATE(new) will be passed when the shell view is opened }
  1557. {  within an ActiveX control, which is not a UI active. In this case, }
  1558. {  the shell view should not merge menus or put toolbas. To be compatible }
  1559. {  with Win95 client, we don't pass this value unless the view supports }
  1560. {  IShellView2. }
  1561.  
  1562. {   The shell view should not change focus within this member function. }
  1563. {  The shell view should not hook the WM_KILLFOCUS message to remerge }
  1564. {  menuitems. However, the shell view typically hook the WM_SETFOCUS }
  1565. {  message, and re-merge the menu after calling IShellBrowser. }
  1566. {  OnViewWindowActivated. }
  1567.  
  1568.  
  1569. { IShellView.Refresh() }
  1570.  
  1571. {   The explorer calls this member when the view needs to refresh its }
  1572. {  contents (such as when the user hits F5 key). }
  1573.  
  1574.  
  1575. { IShellView.CreateViewWindow }
  1576.  
  1577. {   This member creates the view window (right-pane of the explorer or the }
  1578. {  client window of the folder window). }
  1579.  
  1580.  
  1581. { IShellView.DestroyViewWindow }
  1582.  
  1583. {   This member destroys the view window. }
  1584.  
  1585.  
  1586. { IShellView.GetCurrentInfo }
  1587.  
  1588. {   This member returns the folder settings. }
  1589.  
  1590.  
  1591. { IShellView.AddPropertySHeetPages }
  1592.  
  1593. {   The explorer calls this member when it is opening the option property }
  1594. {  sheet. This allows the view to add additional pages to it. }
  1595.  
  1596.  
  1597. { IShellView.SaveViewState() }
  1598.  
  1599. {   The explorer calls this member when the shell view is supposed to }
  1600. {  store its view settings. The shell view is supposed to get a view }
  1601. {  stream by calling IShellBrowser.GetViewStateStream and store the }
  1602. {  current view state into that stream. }
  1603.  
  1604.  
  1605. { IShellView.SelectItem(pidlItem, uFlags) }
  1606.  
  1607. {   The explorer calls this member to change the selection state of }
  1608. {  item(s) within the shell view window.  If pidlItem is NULL and uFlags }
  1609. {  is SVSI_DESELECTOTHERS, all items should be deselected. }
  1610.  
  1611. { ------------------------------------------------------------------------- }
  1612.  
  1613. { uState values for IShellView.UIActivate }
  1614.  
  1615.   {$EXTERNALSYM TSVUIAEnums}
  1616.   TSVUIAEnums = (
  1617.     SVUIA_DEACTIVATE,
  1618.     SVUIA_ACTIVATE_NOFOCUS,
  1619.     SVUIA_ACTIVATE_FOCUS,
  1620.     SVUIA_INPLACEACTIVATE               { new flag for IShellView2 }
  1621.   );
  1622.  
  1623.   {$EXTERNALSYM IShellView}
  1624.   IShellView = interface(IOleWindow)
  1625.     [SID_IShellView]
  1626.     function TranslateAccelerator(var Msg: TMsg): HResult; stdcall;
  1627.     function EnableModeless(Enable: Boolean): HResult; stdcall;
  1628.     function UIActivate(State: UINT): HResult; stdcall;
  1629.     function Refresh: HResult; stdcall;
  1630.     function CreateViewWindow(PrevView: IShellView;
  1631.       var FolderSettings: TFolderSettings; ShellBrowser: IShellBrowser;
  1632.       var Rect: TRect; out Wnd: HWND): HResult; stdcall;
  1633.     function DestroyViewWindow: HResult; stdcall;
  1634.     function GetCurrentInfo(out FolderSettings: TFolderSettings): HResult; stdcall;
  1635.     function AddPropertySheetPages(Reseved: DWORD;
  1636.       lpfnAddPage: TFNAddPropSheetPage; lParam: LPARAM): HResult; stdcall;
  1637.     function SaveViewState: HResult; stdcall;
  1638.     function SelectItem(pidl: PItemIDList; flags: UINT): HResult; stdcall;
  1639.     function GetItemObject(Item: UINT; iid: TIID; IPtr: Pointer): HResult; stdcall;
  1640.   end;
  1641.  
  1642. const
  1643.   {$EXTERNALSYM SV2GV_CURRENTVIEW}
  1644.   SV2GV_CURRENTVIEW     = -1;
  1645.   {$EXTERNALSYM SV2GV_DEFAULTVIEW}
  1646.   SV2GV_DEFAULTVIEW     = -2;
  1647.  
  1648. type
  1649.   {$EXTERNALSYM SHELLVIEWID}
  1650.   SHELLVIEWID = TGUID;
  1651.   TShellViewID = SHELLVIEWID;
  1652.   PShellViewID = ^TShellViewID;
  1653.  
  1654.   PSV2CreateParams = ^TSV2CreateParams;
  1655.   {$EXTERNALSYM _SV2CVW2_PARAMS}
  1656.   _SV2CVW2_PARAMS = record
  1657.     cbSize: DWORD;
  1658.     psvPrev: IShellView;
  1659.     pfs: PFolderSettings;
  1660.     psbOwner: IShellBrowser;
  1661.     prcView: PRect;
  1662.     pvid: PShellViewID;
  1663.     hwndView: HWND;
  1664.   end;
  1665.   TSV2CreateParams = _SV2CVW2_PARAMS;
  1666.   {$EXTERNALSYM SV2CVW2_PARAMS}
  1667.   SV2CVW2_PARAMS = _SV2CVW2_PARAMS;
  1668.  
  1669.  
  1670.   {$EXTERNALSYM IShellView2}
  1671.   IShellView2 = interface(IShellView)
  1672.     [SID_IShellView2]
  1673.     function GetView(pvid: PShellViewID; uView: ULONG): HResult; stdcall;
  1674.     function CreateViewWindow2(SV2CreateParams: PSV2CreateParams): HResult; stdcall;
  1675.   end;
  1676.  
  1677. { ------------------------------------------------------------------------- }
  1678.  
  1679. const
  1680.   {$EXTERNALSYM STRRET_WSTR}
  1681.   STRRET_WSTR         = $0000;          { Use STRRET.pOleStr }
  1682.   {$EXTERNALSYM STRRET_OFFSET}
  1683.   STRRET_OFFSET       = $0001;          { Use STRRET.uOffset to Ansi }
  1684.   {$EXTERNALSYM STRRET_CSTR}
  1685.   STRRET_CSTR         = $0002;          { Use STRRET.cStr }
  1686.  
  1687. type
  1688. { record for returning strings from IShellFolder member functions }
  1689.  
  1690.   PSTRRet = ^TStrRet;
  1691.   {$EXTERNALSYM _STRRET}
  1692.   _STRRET = record
  1693.      uType: UINT;              { One of the STRRET_* values }
  1694.      case Integer of
  1695.        0: (pOleStr: LPWSTR);                    { OLESTR that will be freed }
  1696.        1: (pStr: LPSTR);                        { ANSI string that will be freed (needed?) }
  1697.        2: (uOffset: UINT);                      { Offset into SHITEMID (ANSI) }
  1698.        3: (cStr: array[0..MAX_PATH-1] of Char); { Buffer to fill in }
  1699.     end;
  1700.   TStrRet = _STRRET;
  1701.   {$EXTERNALSYM STRRET}
  1702.   STRRET = _STRRET;
  1703.  
  1704.  
  1705. { SHGetPathFromIDList }
  1706.  
  1707. { This function assumes the size of the buffer (MAX_PATH). The pidl
  1708.   should point to a file system object. }
  1709.  
  1710. {$EXTERNALSYM SHGetPathFromIDListA}
  1711. function SHGetPathFromIDListA(pidl: PItemIDList; pszPath: PAnsiChar): BOOL; stdcall;
  1712. {$EXTERNALSYM SHGetPathFromIDListW}
  1713. function SHGetPathFromIDListW(pidl: PItemIDList; pszPath: PWideChar): BOOL; stdcall;
  1714. {$EXTERNALSYM SHGetPathFromIDList}
  1715. function SHGetPathFromIDList(pidl: PItemIDList; pszPath: PChar): BOOL; stdcall;
  1716.  
  1717. { SHGetSpecialFolderLocation }
  1718.  
  1719. { Caller should call SHFree to free the returned pidl. }
  1720.  
  1721. const
  1722. { registry entries for special paths are kept in : }
  1723.  
  1724.   {$EXTERNALSYM REGSTR_PATH_SPECIAL_FOLDERS}
  1725.   REGSTR_PATH_SPECIAL_FOLDERS   = REGSTR_PATH_EXPLORER + '\Shell Folders';
  1726.   {$EXTERNALSYM CSIDL_DESKTOP}
  1727.   CSIDL_DESKTOP                       = $0000;
  1728.   {$EXTERNALSYM CSIDL_PROGRAMS}
  1729.   CSIDL_PROGRAMS                      = $0002;
  1730.   {$EXTERNALSYM CSIDL_CONTROLS}
  1731.   CSIDL_CONTROLS                      = $0003;
  1732.   {$EXTERNALSYM CSIDL_PRINTERS}
  1733.   CSIDL_PRINTERS                      = $0004;
  1734.   {$EXTERNALSYM CSIDL_PERSONAL}
  1735.   CSIDL_PERSONAL                      = $0005;
  1736.   {$EXTERNALSYM CSIDL_FAVORITES}
  1737.   CSIDL_FAVORITES                     = $0006;
  1738.   {$EXTERNALSYM CSIDL_STARTUP}
  1739.   CSIDL_STARTUP                       = $0007;
  1740.   {$EXTERNALSYM CSIDL_RECENT}
  1741.   CSIDL_RECENT                        = $0008;
  1742.   {$EXTERNALSYM CSIDL_SENDTO}
  1743.   CSIDL_SENDTO                        = $0009;
  1744.   {$EXTERNALSYM CSIDL_BITBUCKET}
  1745.   CSIDL_BITBUCKET                     = $000a;
  1746.   {$EXTERNALSYM CSIDL_STARTMENU}
  1747.   CSIDL_STARTMENU                     = $000b;
  1748.   {$EXTERNALSYM CSIDL_DESKTOPDIRECTORY}
  1749.   CSIDL_DESKTOPDIRECTORY              = $0010;
  1750.   {$EXTERNALSYM CSIDL_DRIVES}
  1751.   CSIDL_DRIVES                        = $0011;
  1752.   {$EXTERNALSYM CSIDL_NETWORK}
  1753.   CSIDL_NETWORK                       = $0012;
  1754.   {$EXTERNALSYM CSIDL_NETHOOD}
  1755.   CSIDL_NETHOOD                       = $0013;
  1756.   {$EXTERNALSYM CSIDL_FONTS}
  1757.   CSIDL_FONTS                         = $0014;
  1758.   {$EXTERNALSYM CSIDL_TEMPLATES}
  1759.   CSIDL_TEMPLATES                     = $0015;
  1760.   {$EXTERNALSYM CSIDL_COMMON_STARTMENU}
  1761.   CSIDL_COMMON_STARTMENU              = $0016;
  1762.   {$EXTERNALSYM CSIDL_COMMON_PROGRAMS}
  1763.   CSIDL_COMMON_PROGRAMS               = $0017;
  1764.   {$EXTERNALSYM CSIDL_COMMON_STARTUP}
  1765.   CSIDL_COMMON_STARTUP                = $0018;
  1766.   {$EXTERNALSYM CSIDL_COMMON_DESKTOPDIRECTORY}
  1767.   CSIDL_COMMON_DESKTOPDIRECTORY       = $0019;
  1768.   {$EXTERNALSYM CSIDL_APPDATA}
  1769.   CSIDL_APPDATA                       = $001a;
  1770.   {$EXTERNALSYM CSIDL_PRINTHOOD}
  1771.   CSIDL_PRINTHOOD                     = $001b;
  1772.  
  1773. {$EXTERNALSYM SHGetSpecialFolderLocation}
  1774. function SHGetSpecialFolderLocation(hwndOwner: HWND; nFolder: Integer;
  1775.   var ppidl: PItemIDList): HResult; stdcall;
  1776.  
  1777.  
  1778. { SHBrowseForFolder API }
  1779.  
  1780. type
  1781.   {$EXTERNALSYM BFFCALLBACK}
  1782.   BFFCALLBACK = function(Wnd: HWND; uMsg: UINT; lParam, lpData: LPARAM): Integer stdcall;
  1783.   TFNBFFCallBack = type BFFCALLBACK;
  1784.  
  1785.   PBrowseInfoA = ^TBrowseInfoA;
  1786.   PBrowseInfoW = ^TBrowseInfoW;
  1787.   PBrowseInfo = PBrowseInfoA;
  1788.   {$EXTERNALSYM _browseinfoA}
  1789.   _browseinfoA = record
  1790.     hwndOwner: HWND;
  1791.     pidlRoot: PItemIDList;
  1792.     pszDisplayName: PAnsiChar;  { Return display name of item selected. }
  1793.     lpszTitle: PAnsiChar;      { text to go in the banner over the tree. }
  1794.     ulFlags: UINT;           { Flags that control the return stuff }
  1795.     lpfn: TFNBFFCallBack;
  1796.     lParam: LPARAM;          { extra info that's passed back in callbacks }
  1797.     iImage: Integer;         { output var: where to return the Image index. }
  1798.   end;
  1799.   {$EXTERNALSYM _browseinfoW}
  1800.   _browseinfoW = record
  1801.     hwndOwner: HWND;
  1802.     pidlRoot: PItemIDList;
  1803.     pszDisplayName: PWideChar;  { Return display name of item selected. }
  1804.     lpszTitle: PWideChar;      { text to go in the banner over the tree. }
  1805.     ulFlags: UINT;           { Flags that control the return stuff }
  1806.     lpfn: TFNBFFCallBack;
  1807.     lParam: LPARAM;          { extra info that's passed back in callbacks }
  1808.     iImage: Integer;         { output var: where to return the Image index. }
  1809.   end;
  1810.   {$EXTERNALSYM _browseinfo}
  1811.   _browseinfo = _browseinfoA;
  1812.   TBrowseInfoA = _browseinfoA;
  1813.   TBrowseInfoW = _browseinfoW;
  1814.   TBrowseInfo = TBrowseInfoA;
  1815.   {$EXTERNALSYM BROWSEINFOA}
  1816.   BROWSEINFOA = _browseinfoA;
  1817.   {$EXTERNALSYM BROWSEINFOW}
  1818.   BROWSEINFOW = _browseinfoW;
  1819.   {$EXTERNALSYM BROWSEINFO}
  1820.   BROWSEINFO = BROWSEINFOA;
  1821.  
  1822. const
  1823. { Browsing for directory. }
  1824.  
  1825.   {$EXTERNALSYM BIF_RETURNONLYFSDIRS}
  1826.   BIF_RETURNONLYFSDIRS   = $0001;  { For finding a folder to start document searching }
  1827.   {$EXTERNALSYM BIF_DONTGOBELOWDOMAIN}
  1828.   BIF_DONTGOBELOWDOMAIN  = $0002;  { For starting the Find Computer }
  1829.   {$EXTERNALSYM BIF_STATUSTEXT}
  1830.   BIF_STATUSTEXT         = $0004;
  1831.   {$EXTERNALSYM BIF_RETURNFSANCESTORS}
  1832.   BIF_RETURNFSANCESTORS  = $0008;
  1833.  
  1834.   {$EXTERNALSYM BIF_BROWSEFORCOMPUTER}
  1835.   BIF_BROWSEFORCOMPUTER  = $1000;  { Browsing for Computers. }
  1836.   {$EXTERNALSYM BIF_BROWSEFORPRINTER}
  1837.   BIF_BROWSEFORPRINTER   = $2000;  { Browsing for Printers }
  1838.   {$EXTERNALSYM BIF_BROWSEINCLUDEFILES}
  1839.   BIF_BROWSEINCLUDEFILES = $4000;  { Browsing for Everything }
  1840.  
  1841. { message from browser }
  1842.  
  1843.   {$EXTERNALSYM BFFM_INITIALIZED}
  1844.   BFFM_INITIALIZED       = 1;
  1845.   {$EXTERNALSYM BFFM_SELCHANGED}
  1846.   BFFM_SELCHANGED        = 2;
  1847.  
  1848. { messages to browser }
  1849.  
  1850.   {$EXTERNALSYM BFFM_SETSTATUSTEXTA}
  1851.   BFFM_SETSTATUSTEXTA         = WM_USER + 100;
  1852.   {$EXTERNALSYM BFFM_ENABLEOK}
  1853.   BFFM_ENABLEOK               = WM_USER + 101;
  1854.   {$EXTERNALSYM BFFM_SETSELECTIONA}
  1855.   BFFM_SETSELECTIONA          = WM_USER + 102;
  1856.   {$EXTERNALSYM BFFM_SETSELECTIONW}
  1857.   BFFM_SETSELECTIONW          = WM_USER + 103;
  1858.   {$EXTERNALSYM BFFM_SETSTATUSTEXTW}
  1859.   BFFM_SETSTATUSTEXTW         = WM_USER + 104;
  1860.  
  1861. {$IFDEF UNICODE}
  1862.   {$EXTERNALSYM BFFM_SETSTATUSTEXT}
  1863.   BFFM_SETSTATUSTEXT      = BFFM_SETSTATUSTEXTW;
  1864.   {$EXTERNALSYM BFFM_SETSELECTION}
  1865.   BFFM_SETSELECTION       = BFFM_SETSELECTIONW;
  1866. {$ELSE}
  1867.   {$EXTERNALSYM BFFM_SETSTATUSTEXT}
  1868.   BFFM_SETSTATUSTEXT      = BFFM_SETSTATUSTEXTA;
  1869.   {$EXTERNALSYM BFFM_SETSELECTION}
  1870.   BFFM_SETSELECTION       = BFFM_SETSELECTIONA;
  1871. {$ENDIF}
  1872.  
  1873. {$EXTERNALSYM SHBrowseForFolderA}
  1874. function SHBrowseForFolderA(var lpbi: TBrowseInfoA): PItemIDList; stdcall;
  1875. {$EXTERNALSYM SHBrowseForFolderW}
  1876. function SHBrowseForFolderW(var lpbi: TBrowseInfoW): PItemIDList; stdcall;
  1877. {$EXTERNALSYM SHBrowseForFolder}
  1878. function SHBrowseForFolder(var lpbi: TBrowseInfo): PItemIDList; stdcall;
  1879.  
  1880. { SHLoadInProc }
  1881.  
  1882. { When this function is called, the shell calls CoCreateInstance
  1883.   (or equivalent) with CLSCTX_INPROC_SERVER and the specified CLSID
  1884.   from within the shell's process and release it immediately. }
  1885.  
  1886. {$EXTERNALSYM SHLoadInProc}
  1887. function SHLoadInProc(rclsid: TCLSID): HRESULT; stdcall;
  1888.  
  1889. { IEnumIDList interface }
  1890.  
  1891. { IShellFolder.EnumObjects member returns an IEnumIDList object. }
  1892.  
  1893. type
  1894.   {$EXTERNALSYM IEnumIDList}
  1895.   IEnumIDList = interface(IUnknown)
  1896.     [SID_IEnumIDList]
  1897.     function Next(celt: ULONG; out rgelt: PItemIDList;
  1898.       var pceltFetched: ULONG): HResult; stdcall;
  1899.     function Skip(celt: ULONG): HResult; stdcall;
  1900.     function Reset: HResult; stdcall;
  1901.     function Clone(out ppenum: IEnumIDList): HResult; stdcall;
  1902.   end;
  1903.  
  1904. { IShellFolder interface }
  1905.  
  1906. { [Member functions] }
  1907.  
  1908. { IShellFolder.BindToObject(pidl, pbc, riid, ppvOut)
  1909.   This function returns an instance of a sub-folder which is specified
  1910.   by the IDList (pidl).
  1911.  IShellFolder.BindToStorage(pidl, pbc, riid, ppvObj)
  1912.    This function returns a storage instance of a sub-folder which is
  1913.    specified by the IDList (pidl). The shell never calls this member
  1914.    function in the first release of Win95.
  1915.  IShellFolder.CompareIDs(lParam, pidl1, pidl2)
  1916.    This function compares two IDLists and returns the result. The shell
  1917.    explorer always passes 0 as lParam, which indicates 'sort by name'.
  1918.    It should return 0 (as CODE of the scode), if two id indicates the
  1919.    same object; negative value if pidl1 should be placed before pidl2;
  1920.    positive value if pidl2 should be placed before pidl1.
  1921.  IShellFolder.CreateViewObject(hwndOwner, riid, ppvOut)
  1922.    This function creates a view object of the folder itself. The view
  1923.    object is a difference instance from the shell folder object.
  1924.    "hwndOwner" can be used  as the owner window of its dialog box or
  1925.       menu during the lifetime of the view object.
  1926.    instance which has only one reference count. The explorer may create
  1927.    more than one instances of view object from one shell folder object
  1928.    and treat them as separate instances.
  1929.  IShellFolder.GetAttributesOf(cidl, apidl, prgfInOut)
  1930.    This function returns the attributes of specified objects in that
  1931.    folder. 'cidl' and 'apidl' specifies objects. 'apidl' contains only
  1932.    simple IDLists. The explorer initializes *prgfInOut with a set of
  1933.    flags to be evaluated. The shell folder may optimize the operation
  1934.    by not returning unspecified flags.
  1935.  IShellFolder.GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut)
  1936.    This function creates a UI object to be used for specified objects.
  1937.    The shell explorer passes either IID_IDataObject (for transfer operation)
  1938.    or IID_IContextMenu (for context menu operation) as riid.
  1939.  IShellFolder.GetDisplayNameOf
  1940.    This function returns the display name of the specified object.
  1941.    If the ID contains the display name (in the locale character set),
  1942.    it returns the offset to the name. Otherwise, it returns a pointer
  1943.    to the display name string (UNICODE), which is allocated by the
  1944.    task allocator, or fills in a buffer.
  1945.  IShellFolder.SetNameOf
  1946.    This function sets the display name of the specified object.
  1947.    If it changes the ID as well, it returns the new ID which is
  1948.    alocated by the task allocator. }
  1949.  
  1950. const
  1951. { IShellFolder.GetDisplayNameOf/SetNameOf uFlags }
  1952.  
  1953.   {$EXTERNALSYM SHGDN_NORMAL}
  1954.   SHGDN_NORMAL           = 0;         { default (display purpose) }
  1955.   {$EXTERNALSYM SHGDN_INFOLDER}
  1956.   SHGDN_INFOLDER         = 1;         { displayed under a folder (relative) }
  1957.   {$EXTERNALSYM SHGDN_FORADDRESSBAR}
  1958.   SHGDN_FORADDRESSBAR    = $4000;     { for displaying in the address (drives dropdown) bar }
  1959.   {$EXTERNALSYM SHGDN_FORPARSING}
  1960.   SHGDN_FORPARSING       = $8000;     { for ParseDisplayName or path }
  1961.  
  1962. { IShellFolder.EnumObjects }
  1963.  
  1964.   {$EXTERNALSYM SHCONTF_FOLDERS}
  1965.   SHCONTF_FOLDERS         = 32;       { for shell browser }
  1966.   {$EXTERNALSYM SHCONTF_NONFOLDERS}
  1967.   SHCONTF_NONFOLDERS      = 64;       { for default view }
  1968.   {$EXTERNALSYM SHCONTF_INCLUDEHIDDEN}
  1969.   SHCONTF_INCLUDEHIDDEN   = 128;      { for hidden/system objects }
  1970.  
  1971. { IShellFolder.GetAttributesOf flags }
  1972.  
  1973.   {$EXTERNALSYM SFGAO_CANCOPY}
  1974.   SFGAO_CANCOPY           = DROPEFFECT_COPY; { Objects can be copied }
  1975.   {$EXTERNALSYM SFGAO_CANMOVE}
  1976.   SFGAO_CANMOVE           = DROPEFFECT_MOVE; { Objects can be moved }
  1977.   {$EXTERNALSYM SFGAO_CANLINK}
  1978.   SFGAO_CANLINK           = DROPEFFECT_LINK; { Objects can be linked }
  1979.   {$EXTERNALSYM SFGAO_CANRENAME}
  1980.   SFGAO_CANRENAME         = $00000010;       { Objects can be renamed }
  1981.   {$EXTERNALSYM SFGAO_CANDELETE}
  1982.   SFGAO_CANDELETE         = $00000020;       { Objects can be deleted }
  1983.   {$EXTERNALSYM SFGAO_HASPROPSHEET}
  1984.   SFGAO_HASPROPSHEET      = $00000040;       { Objects have property sheets }
  1985.   {$EXTERNALSYM SFGAO_DROPTARGET}
  1986.   SFGAO_DROPTARGET        = $00000100;       { Objects are drop target }
  1987.   {$EXTERNALSYM SFGAO_CAPABILITYMASK}
  1988.   SFGAO_CAPABILITYMASK    = $00000177;
  1989.   {$EXTERNALSYM SFGAO_LINK}
  1990.   SFGAO_LINK              = $00010000;       { Shortcut (link) }
  1991.   {$EXTERNALSYM SFGAO_SHARE}
  1992.   SFGAO_SHARE             = $00020000;       { shared }
  1993.   {$EXTERNALSYM SFGAO_READONLY}
  1994.   SFGAO_READONLY          = $00040000;       { read-only }
  1995.   {$EXTERNALSYM SFGAO_GHOSTED}
  1996.   SFGAO_GHOSTED           = $00080000;       { ghosted icon }
  1997.   {$EXTERNALSYM SFGAO_DISPLAYATTRMASK}
  1998.   SFGAO_DISPLAYATTRMASK   = $000F0000;
  1999.   {$EXTERNALSYM SFGAO_FILESYSANCESTOR}
  2000.   SFGAO_FILESYSANCESTOR   = $10000000;       { It contains file system folder }
  2001.   {$EXTERNALSYM SFGAO_FOLDER}
  2002.   SFGAO_FOLDER            = $20000000;       { It's a folder. }
  2003.   {$EXTERNALSYM SFGAO_FILESYSTEM}
  2004.   SFGAO_FILESYSTEM        = $40000000;       { is a file system thing (file/folder/root) }
  2005.   {$EXTERNALSYM SFGAO_HASSUBFOLDER}
  2006.   SFGAO_HASSUBFOLDER      = $80000000;       { Expandable in the map pane }
  2007.   {$EXTERNALSYM SFGAO_CONTENTSMASK}
  2008.   SFGAO_CONTENTSMASK      = $80000000;
  2009.   {$EXTERNALSYM SFGAO_VALIDATE}
  2010.   SFGAO_VALIDATE          = $01000000;       { invalidate cached information }
  2011.   {$EXTERNALSYM SFGAO_REMOVABLE}
  2012.   SFGAO_REMOVABLE         = $02000000;       { is this removeable media? }
  2013.   {$EXTERNALSYM SFGAO_COMPRESSED}
  2014.   SFGAO_COMPRESSED        = $04000000;       { Object is compressed (use alt color) }
  2015.  
  2016. type
  2017.   {$EXTERNALSYM IShellFolder}
  2018.   IShellFolder = interface(IUnknown)
  2019.     [SID_IShellFolder]
  2020.     function ParseDisplayName(hwndOwner: HWND;
  2021.       pbcReserved: Pointer; lpszDisplayName: POLESTR; out pchEaten: ULONG;
  2022.       out ppidl: PItemIDList; var dwAttributes: ULONG): HResult; stdcall;
  2023.     function EnumObjects(hwndOwner: HWND; grfFlags: DWORD;
  2024.       out EnumIDList: IEnumIDList): HResult; stdcall;
  2025.     function BindToObject(pidl: PItemIDList; pbcReserved: Pointer;
  2026.       const riid: TIID; out ppvOut: Pointer): HResult; stdcall;
  2027.     function BindToStorage(pidl: PItemIDList; pbcReserved: Pointer;
  2028.       const riid: TIID; out ppvObj: Pointer): HResult; stdcall;
  2029.     function CompareIDs(lParam: LPARAM;
  2030.       pidl1, pidl2: PItemIDList): HResult; stdcall;
  2031.     function CreateViewObject(hwndOwner: HWND; const riid: TIID;
  2032.       out ppvOut: Pointer): HResult; stdcall;
  2033.     function GetAttributesOf(cidl: UINT; var apidl: PItemIDList;
  2034.       var rgfInOut: UINT): HResult; stdcall;
  2035.     function GetUIObjectOf(hwndOwner: HWND; cidl: UINT; var apidl: PItemIDList;
  2036.       const riid: TIID; prgfInOut: Pointer; out ppvOut: Pointer): HResult; stdcall;
  2037.     function GetDisplayNameOf(pidl: PItemIDList; uFlags: DWORD;
  2038.       var lpName: TStrRet): HResult; stdcall;
  2039.     function SetNameOf(hwndOwner: HWND; pidl: PItemIDList; lpszName: POLEStr;
  2040.       uFlags: DWORD; var ppidlOut: PItemIDList): HResult; stdcall;
  2041.   end;
  2042.  
  2043. { Helper function which returns a IShellFolder interface to the desktop
  2044.   folder. This is equivalent to call CoCreateInstance with CLSID_ShellDesktop. }
  2045.  
  2046. {$EXTERNALSYM SHGetDesktopFolder}
  2047. function SHGetDesktopFolder(var ppshf: IShellFolder): HResult; stdcall;
  2048.  
  2049. const
  2050. { Clipboard format which may be supported by IDataObject from system
  2051.   defined shell folders (such as directories, network, ...). }
  2052.  
  2053.   {$EXTERNALSYM CFSTR_SHELLIDLIST}
  2054.   CFSTR_SHELLIDLIST           = 'Shell IDList Array';     { CF_IDLIST }
  2055.   {$EXTERNALSYM CFSTR_SHELLIDLISTOFFSET}
  2056.   CFSTR_SHELLIDLISTOFFSET     = 'Shell Object Offsets';   { CF_OBJECTPOSITIONS }
  2057.   {$EXTERNALSYM CFSTR_NETRESOURCES}
  2058.   CFSTR_NETRESOURCES          = 'Net Resource';           { CF_NETRESOURCE }
  2059.   {$EXTERNALSYM CFSTR_FILEDESCRIPTORA}
  2060.   CFSTR_FILEDESCRIPTORA       = 'FileGroupDescriptor';    { CF_FILEGROUPDESCRIPTORA }
  2061.   {$EXTERNALSYM CFSTR_FILEDESCRIPTORW}
  2062.   CFSTR_FILEDESCRIPTORW       = 'FileGroupDescriptorW';   { CF_FILEGROUPDESCRIPTORW }
  2063.   {$EXTERNALSYM CFSTR_FILECONTENTS}
  2064.   CFSTR_FILECONTENTS          = 'FileContents';           { CF_FILECONTENTS }
  2065.   {$EXTERNALSYM CFSTR_FILENAMEA}
  2066.   CFSTR_FILENAMEA             = 'FileName';               { CF_FILENAMEA }
  2067.   {$EXTERNALSYM CFSTR_FILENAMEW}
  2068.   CFSTR_FILENAMEW             = 'FileNameW';              { CF_FILENAMEW }
  2069.   {$EXTERNALSYM CFSTR_PRINTERGROUP}
  2070.   CFSTR_PRINTERGROUP          = 'PrinterFriendlyName';    { CF_PRINTERS }
  2071.   {$EXTERNALSYM CFSTR_FILENAMEMAPA}
  2072.   CFSTR_FILENAMEMAPA          = 'FileNameMap';            { CF_FILENAMEMAPA }
  2073.   {$EXTERNALSYM CFSTR_FILENAMEMAPW}
  2074.   CFSTR_FILENAMEMAPW          = 'FileNameMapW';           { CF_FILENAMEMAPW }
  2075.   {$EXTERNALSYM CFSTR_PREFERREDDROPEFFECT}
  2076.   CFSTR_PREFERREDDROPEFFECT   = 'Preferred DropEffect';
  2077.  
  2078. {$IFDEF UNICODE}
  2079.   {$EXTERNALSYM CFSTR_FILEDESCRIPTOR}
  2080.   CFSTR_FILEDESCRIPTOR        = CFSTR_FILEDESCRIPTORW;
  2081.   {$EXTERNALSYM CFSTR_FILENAME}
  2082.   CFSTR_FILENAME              = CFSTR_FILENAMEW;
  2083.   {$EXTERNALSYM CFSTR_FILENAMEMAP}
  2084.   CFSTR_FILENAMEMAP           = CFSTR_FILENAMEMAPW;
  2085. {$ELSE}
  2086.   {$EXTERNALSYM CFSTR_FILEDESCRIPTOR}
  2087.   CFSTR_FILEDESCRIPTOR        = CFSTR_FILEDESCRIPTORA;
  2088.   {$EXTERNALSYM CFSTR_FILENAME}
  2089.   CFSTR_FILENAME              = CFSTR_FILENAMEA;
  2090.   {$EXTERNALSYM CFSTR_FILENAMEMAP}
  2091.   CFSTR_FILENAMEMAP           = CFSTR_FILENAMEMAPA;
  2092. {$ENDIF}
  2093.  
  2094.  
  2095. { CF_OBJECTPOSITIONS }
  2096.  
  2097.   {$EXTERNALSYM DVASPECT_SHORTNAME}
  2098.   DVASPECT_SHORTNAME     = 2; { use for CF_HDROP to get short name version }
  2099.  
  2100.  
  2101. type
  2102. { format of CF_NETRESOURCE }
  2103.  
  2104.   PNResArray = ^TNResArray;
  2105.   {$EXTERNALSYM _NRESARRAY}
  2106.   _NRESARRAY = record
  2107.     cItems: UINT;
  2108.     nr: array[0..0] of TNetResource;
  2109.   end;
  2110.   TNResArray = _NRESARRAY;
  2111.   {$EXTERNALSYM NRESARRAY}
  2112.   NRESARRAY = _NRESARRAY;
  2113.  
  2114.  
  2115. { format of CF_IDLIST }
  2116.  
  2117.   PIDA = ^TIDA;
  2118.   {$EXTERNALSYM _IDA}
  2119.   _IDA = record
  2120.     cidl: UINT;                      { number of relative IDList }
  2121.     aoffset: array[0..0] of UINT;    { [0]: folder IDList, [1]-[cidl]: item IDList }
  2122.   end;
  2123.   TIDA = _IDA;
  2124.   {$EXTERNALSYM CIDA}
  2125.   CIDA = _IDA;
  2126.  
  2127.  
  2128.  
  2129. const
  2130. { FILEDESCRIPTOR.dwFlags field indicate which fields are to be used }
  2131.  
  2132.   {$EXTERNALSYM FD_CLSID}
  2133.   FD_CLSID            = $0001;
  2134.   {$EXTERNALSYM FD_SIZEPOINT}
  2135.   FD_SIZEPOINT        = $0002;
  2136.   {$EXTERNALSYM FD_ATTRIBUTES}
  2137.   FD_ATTRIBUTES       = $0004;
  2138.   {$EXTERNALSYM FD_CREATETIME}
  2139.   FD_CREATETIME       = $0008;
  2140.   {$EXTERNALSYM FD_ACCESSTIME}
  2141.   FD_ACCESSTIME       = $0010;
  2142.   {$EXTERNALSYM FD_WRITESTIME}
  2143.   FD_WRITESTIME       = $0020;
  2144.   {$EXTERNALSYM FD_FILESIZE}
  2145.   FD_FILESIZE         = $0040;
  2146.   {$EXTERNALSYM FD_LINKUI}
  2147.   FD_LINKUI           = $8000;       { 'link' UI is prefered }
  2148.  
  2149. type
  2150.   PFileDescriptorA = ^TFileDescriptorA;
  2151.   PFileDescriptorW = ^TFileDescriptorW;
  2152.   PFileDescriptor = PFileDescriptorA;
  2153.   {$EXTERNALSYM _FILEDESCRIPTORA}
  2154.   _FILEDESCRIPTORA = record
  2155.     dwFlags: DWORD;
  2156.     clsid: TCLSID;
  2157.     sizel: TSize;
  2158.     pointl: TPoint;
  2159.     dwFileAttributes: DWORD;
  2160.     ftCreationTime: TFileTime;
  2161.     ftLastAccessTime: TFileTime;
  2162.     ftLastWriteTime: TFileTime;
  2163.     nFileSizeHigh: DWORD;
  2164.     nFileSizeLow: DWORD;
  2165.     cFileName: array[0..MAX_PATH-1] of AnsiChar;
  2166.   end;
  2167.   {$EXTERNALSYM _FILEDESCRIPTORW}
  2168.   _FILEDESCRIPTORW = record
  2169.     dwFlags: DWORD;
  2170.     clsid: TCLSID;
  2171.     sizel: TSize;
  2172.     pointl: TPoint;
  2173.     dwFileAttributes: DWORD;
  2174.     ftCreationTime: TFileTime;
  2175.     ftLastAccessTime: TFileTime;
  2176.     ftLastWriteTime: TFileTime;
  2177.     nFileSizeHigh: DWORD;
  2178.     nFileSizeLow: DWORD;
  2179.     cFileName: array[0..MAX_PATH-1] of WideChar;
  2180.   end;
  2181.   {$EXTERNALSYM _FILEDESCRIPTOR}
  2182.   _FILEDESCRIPTOR = _FILEDESCRIPTORA;
  2183.   TFileDescriptorA = _FILEDESCRIPTORA;
  2184.   TFileDescriptorW = _FILEDESCRIPTORW;
  2185.   TFileDescriptor = TFileDescriptorA;
  2186.   {$EXTERNALSYM FILEDESCRIPTORA}
  2187.   FILEDESCRIPTORA = _FILEDESCRIPTORA;
  2188.   {$EXTERNALSYM FILEDESCRIPTORW}
  2189.   FILEDESCRIPTORW = _FILEDESCRIPTORW;
  2190.   {$EXTERNALSYM FILEDESCRIPTOR}
  2191.   FILEDESCRIPTOR = FILEDESCRIPTORA;
  2192.  
  2193. { format of CF_FILEGROUPDESCRIPTOR }
  2194.  
  2195.   PFileGroupDescriptorA = ^TFileGroupDescriptorA;
  2196.   PFileGroupDescriptorW = ^TFileGroupDescriptorW;
  2197.   PFileGroupDescriptor = PFileGroupDescriptorA;
  2198.   {$EXTERNALSYM _FILEGROUPDESCRIPTORA}
  2199.   _FILEGROUPDESCRIPTORA = record
  2200.     cItems: UINT;
  2201.     fgd: array[0..0] of TFileDescriptor;
  2202.   end;
  2203.   {$EXTERNALSYM _FILEGROUPDESCRIPTORW}
  2204.   _FILEGROUPDESCRIPTORW = record
  2205.     cItems: UINT;
  2206.     fgd: array[0..0] of TFileDescriptor;
  2207.   end;
  2208.   {$EXTERNALSYM _FILEGROUPDESCRIPTOR}
  2209.   _FILEGROUPDESCRIPTOR = _FILEGROUPDESCRIPTORA;
  2210.   TFileGroupDescriptorA = _FILEGROUPDESCRIPTORA;
  2211.   TFileGroupDescriptorW = _FILEGROUPDESCRIPTORW;
  2212.   TFileGroupDescriptor = TFileGroupDescriptorA;
  2213.   {$EXTERNALSYM FILEGROUPDESCRIPTORA}
  2214.   FILEGROUPDESCRIPTORA = _FILEGROUPDESCRIPTORA;
  2215.   {$EXTERNALSYM FILEGROUPDESCRIPTORW}
  2216.   FILEGROUPDESCRIPTORW = _FILEGROUPDESCRIPTORW;
  2217.   {$EXTERNALSYM FILEGROUPDESCRIPTOR}
  2218.   FILEGROUPDESCRIPTOR = FILEGROUPDESCRIPTORA;
  2219.  
  2220. { format of CF_HDROP and CF_PRINTERS, in the HDROP case the data that follows
  2221.   is a double null terinated list of file names, for printers they are printer
  2222.   friendly names }
  2223.  
  2224.   PDropFiles = ^TDropFiles;
  2225.   {$EXTERNALSYM _DROPFILES}
  2226.   _DROPFILES = record
  2227.     pFiles: DWORD;                       { offset of file list }
  2228.     pt: TPoint;                          { drop point (client coords) }
  2229.     fNC: BOOL;                           { is it on NonClient area }
  2230.                      { and pt is in screen coords }
  2231.     fWide: BOOL;                         { WIDE character switch }
  2232.   end;
  2233.   TDropFiles = _DROPFILES;
  2234.   {$EXTERNALSYM DROPFILES}
  2235.   DROPFILES = _DROPFILES;
  2236.  
  2237.  
  2238. { File System Notification APIs }
  2239.  
  2240. const
  2241. { File System Notification flags }
  2242.  
  2243.   {$EXTERNALSYM SHCNE_RENAMEITEM}
  2244.   SHCNE_RENAMEITEM          = $00000001;
  2245.   {$EXTERNALSYM SHCNE_CREATE}
  2246.   SHCNE_CREATE              = $00000002;
  2247.   {$EXTERNALSYM SHCNE_DELETE}
  2248.   SHCNE_DELETE              = $00000004;
  2249.   {$EXTERNALSYM SHCNE_MKDIR}
  2250.   SHCNE_MKDIR               = $00000008;
  2251.   {$EXTERNALSYM SHCNE_RMDIR}
  2252.   SHCNE_RMDIR               = $00000010;
  2253.   {$EXTERNALSYM SHCNE_MEDIAINSERTED}
  2254.   SHCNE_MEDIAINSERTED       = $00000020;
  2255.   {$EXTERNALSYM SHCNE_MEDIAREMOVED}
  2256.   SHCNE_MEDIAREMOVED        = $00000040;
  2257.   {$EXTERNALSYM SHCNE_DRIVEREMOVED}
  2258.   SHCNE_DRIVEREMOVED        = $00000080;
  2259.   {$EXTERNALSYM SHCNE_DRIVEADD}
  2260.   SHCNE_DRIVEADD            = $00000100;
  2261.   {$EXTERNALSYM SHCNE_NETSHARE}
  2262.   SHCNE_NETSHARE            = $00000200;
  2263.   {$EXTERNALSYM SHCNE_NETUNSHARE}
  2264.   SHCNE_NETUNSHARE          = $00000400;
  2265.   {$EXTERNALSYM SHCNE_ATTRIBUTES}
  2266.   SHCNE_ATTRIBUTES          = $00000800;
  2267.   {$EXTERNALSYM SHCNE_UPDATEDIR}
  2268.   SHCNE_UPDATEDIR           = $00001000;
  2269.   {$EXTERNALSYM SHCNE_UPDATEITEM}
  2270.   SHCNE_UPDATEITEM          = $00002000;
  2271.   {$EXTERNALSYM SHCNE_SERVERDISCONNECT}
  2272.   SHCNE_SERVERDISCONNECT    = $00004000;
  2273.   {$EXTERNALSYM SHCNE_UPDATEIMAGE}
  2274.   SHCNE_UPDATEIMAGE         = $00008000;
  2275.   {$EXTERNALSYM SHCNE_DRIVEADDGUI}
  2276.   SHCNE_DRIVEADDGUI         = $00010000;
  2277.   {$EXTERNALSYM SHCNE_RENAMEFOLDER}
  2278.   SHCNE_RENAMEFOLDER        = $00020000;
  2279.   {$EXTERNALSYM SHCNE_FREESPACE}
  2280.   SHCNE_FREESPACE           = $00040000;
  2281.   {$EXTERNALSYM SHCNE_EXTENDED_EVENT}
  2282.   SHCNE_EXTENDED_EVENT      = $00080000;
  2283.  
  2284.   {$EXTERNALSYM SHCNE_ASSOCCHANGED}
  2285.   SHCNE_ASSOCCHANGED        = $08000000;
  2286.  
  2287.   {$EXTERNALSYM SHCNE_DISKEVENTS}
  2288.   SHCNE_DISKEVENTS          = $0002381F;
  2289.   {$EXTERNALSYM SHCNE_GLOBALEVENTS}
  2290.   SHCNE_GLOBALEVENTS        = $0C0581E0; { Events that dont match pidls first }
  2291.   {$EXTERNALSYM SHCNE_ALLEVENTS}
  2292.   SHCNE_ALLEVENTS           = $7FFFFFFF;
  2293.   {$EXTERNALSYM SHCNE_INTERRUPT}
  2294.   SHCNE_INTERRUPT           = $80000000; { The presence of this flag indicates }
  2295.                      { that the event was generated by an }
  2296.                      { interrupt.  It is stripped out before }
  2297.                      { the clients of SHCNNotify_ see it. }
  2298.  
  2299.   {$EXTERNALSYM SHCNEE_THEMECHANGED}
  2300.   SHCNEE_THEMECHANGED       = $00000001;
  2301.                     
  2302. { uFlags & SHCNF_TYPE is an ID which indicates what dwItem1 and dwItem2 mean }
  2303.  
  2304.   {$EXTERNALSYM SHCNF_IDLIST}
  2305.   SHCNF_IDLIST          = $0000;        { LPITEMIDLIST }
  2306.   {$EXTERNALSYM SHCNF_PATHA}
  2307.   SHCNF_PATHA           = $0001;        { path name }
  2308.   {$EXTERNALSYM SHCNF_PRINTERA}
  2309.   SHCNF_PRINTERA        = $0002;        { printer friendly name }
  2310.   {$EXTERNALSYM SHCNF_DWORD}
  2311.   SHCNF_DWORD           = $0003;        { DWORD }
  2312.   {$EXTERNALSYM SHCNF_PATHW}
  2313.   SHCNF_PATHW           = $0005;        { path name }
  2314.   {$EXTERNALSYM SHCNF_PRINTERW}
  2315.   SHCNF_PRINTERW        = $0006;        { printer friendly name }
  2316.   {$EXTERNALSYM SHCNF_TYPE}
  2317.   SHCNF_TYPE            = $00FF;
  2318.   {$EXTERNALSYM SHCNF_FLUSH}
  2319.   SHCNF_FLUSH           = $1000;
  2320.   {$EXTERNALSYM SHCNF_FLUSHNOWAIT}
  2321.   SHCNF_FLUSHNOWAIT     = $2000;
  2322.  
  2323. {$IFDEF UNICODE}
  2324.   {$EXTERNALSYM SHCNF_PATH}
  2325.   SHCNF_PATH          = SHCNF_PATHW;
  2326.   {$EXTERNALSYM SHCNF_PRINTER}
  2327.   SHCNF_PRINTER       = SHCNF_PRINTERW;
  2328. {$ELSE}
  2329.   {$EXTERNALSYM SHCNF_PATH}
  2330.   SHCNF_PATH          = SHCNF_PATHA;
  2331.   {$EXTERNALSYM SHCNF_PRINTER}
  2332.   SHCNF_PRINTER       = SHCNF_PRINTERA;
  2333. {$ENDIF}
  2334.  
  2335. { APIs }
  2336.  
  2337. {$EXTERNALSYM SHChangeNotify}
  2338. procedure SHChangeNotify(wEventId: Longint; uFlags: UINT;
  2339.   dwItem1, dwItem2: Pointer); stdcall;
  2340. {$EXTERNALSYM SHAddToRecentDocs}
  2341. procedure SHAddToRecentDocs(uFlags: UINT; pv: Pointer); stdcall;
  2342. {$EXTERNALSYM SHGetInstanceExplorer}
  2343. function SHGetInstanceExplorer(var ppUnk: IUnknown): HResult; stdcall;
  2344.  
  2345. { SHAddToRecentDocs }
  2346.  
  2347. const
  2348.   {$EXTERNALSYM SHARD_PIDL}
  2349.   SHARD_PIDL          = $00000001;
  2350.   {$EXTERNALSYM SHARD_PATHA}
  2351.   SHARD_PATHA         = $00000002;
  2352.   {$EXTERNALSYM SHARD_PATHW}
  2353.   SHARD_PATHW         = $00000003;
  2354.  
  2355. {$IFDEF UNICODE}
  2356.   {$EXTERNALSYM SHARD_PATH}
  2357.   SHARD_PATH      = SHARD_PATHW;
  2358. {$ELSE}
  2359.   {$EXTERNALSYM SHARD_PATH}
  2360.   SHARD_PATH      = SHARD_PATHA;
  2361. {$ENDIF}
  2362.  
  2363.  
  2364. { SHGetDataFromIDList}
  2365.  
  2366. const
  2367.   {$EXTERNALSYM SHGDFIL_FINDDATA}
  2368.   SHGDFIL_FINDDATA            = 1;
  2369.   {$EXTERNALSYM SHGDFIL_NETRESOURCE}
  2370.   SHGDFIL_NETRESOURCE         = 2;
  2371.   {$EXTERNALSYM SHGDFIL_DESCRIPTIONID}
  2372.   SHGDFIL_DESCRIPTIONID       = 3;
  2373.  
  2374.   {$EXTERNALSYM SHDID_ROOT_REGITEM}
  2375.   SHDID_ROOT_REGITEM              = 1;
  2376.   {$EXTERNALSYM SHDID_FS_FILE}
  2377.   SHDID_FS_FILE                   = 2;
  2378.   {$EXTERNALSYM SHDID_FS_DIRECTORY}
  2379.   SHDID_FS_DIRECTORY              = 3;
  2380.   {$EXTERNALSYM SHDID_FS_OTHER}
  2381.   SHDID_FS_OTHER                  = 4;
  2382.   {$EXTERNALSYM SHDID_COMPUTER_DRIVE35}
  2383.   SHDID_COMPUTER_DRIVE35          = 5;
  2384.   {$EXTERNALSYM SHDID_COMPUTER_DRIVE525}
  2385.   SHDID_COMPUTER_DRIVE525         = 6;
  2386.   {$EXTERNALSYM SHDID_COMPUTER_REMOVABLE}
  2387.   SHDID_COMPUTER_REMOVABLE        = 7;
  2388.   {$EXTERNALSYM SHDID_COMPUTER_FIXED}
  2389.   SHDID_COMPUTER_FIXED            = 8;
  2390.   {$EXTERNALSYM SHDID_COMPUTER_NETDRIVE}
  2391.   SHDID_COMPUTER_NETDRIVE         = 9;
  2392.   {$EXTERNALSYM SHDID_COMPUTER_CDROM}
  2393.   SHDID_COMPUTER_CDROM            = 10;
  2394.   {$EXTERNALSYM SHDID_COMPUTER_RAMDISK}
  2395.   SHDID_COMPUTER_RAMDISK          = 11;
  2396.   {$EXTERNALSYM SHDID_COMPUTER_OTHER}
  2397.   SHDID_COMPUTER_OTHER            = 12;
  2398.   {$EXTERNALSYM SHDID_NET_DOMAIN}
  2399.   SHDID_NET_DOMAIN                = 13;
  2400.   {$EXTERNALSYM SHDID_NET_SERVER}
  2401.   SHDID_NET_SERVER                = 14;
  2402.   {$EXTERNALSYM SHDID_NET_SHARE}
  2403.   SHDID_NET_SHARE                 = 15;
  2404.   {$EXTERNALSYM SHDID_NET_RESTOFNET}
  2405.   SHDID_NET_RESTOFNET             = 16;
  2406.   {$EXTERNALSYM SHDID_NET_OTHER}
  2407.   SHDID_NET_OTHER                 = 17;
  2408.  
  2409. type
  2410.   PSHDescriptionID = ^TSHDescriptionID;
  2411.   {$EXTERNALSYM _SHDESCRIPTIONID}
  2412.   _SHDESCRIPTIONID = record
  2413.     dwDescriptionId: DWORD;
  2414.     Id: TCLSID;
  2415.   end;
  2416.   TSHDescriptionID = _SHDESCRIPTIONID;
  2417.   {$EXTERNALSYM SHDESCRIPTIONID}
  2418.   SHDESCRIPTIONID = _SHDESCRIPTIONID;
  2419.  
  2420.  
  2421. {$EXTERNALSYM SHGetDataFromIDListA}
  2422. function SHGetDataFromIDListA(psf: IShellFolder; pidl: PItemIDList;
  2423.   nFormat: Integer; ptr: Pointer; cb: Integer): HResult; stdcall;
  2424. {$EXTERNALSYM SHGetDataFromIDListW}
  2425. function SHGetDataFromIDListW(psf: IShellFolder; pidl: PItemIDList;
  2426.   nFormat: Integer; ptr: Pointer; cb: Integer): HResult; stdcall;
  2427. {$EXTERNALSYM SHGetDataFromIDList}
  2428. function SHGetDataFromIDList(psf: IShellFolder; pidl: PItemIDList;
  2429.   nFormat: Integer; ptr: Pointer; cb: Integer): HResult; stdcall;
  2430.  
  2431. implementation
  2432.  
  2433. const
  2434.   shell32 = 'shell32.dll';
  2435.  
  2436. procedure SHAddToRecentDocs;             external shell32 name 'SHAddToRecentDocs';
  2437. function SHBrowseForFolderA;          external shell32 name 'SHBrowseForFolderA';
  2438. function SHBrowseForFolderW;          external shell32 name 'SHBrowseForFolderW';
  2439. function SHBrowseForFolder;          external shell32 name 'SHBrowseForFolderA';
  2440. procedure SHChangeNotify;                external shell32 name 'SHChangeNotify';
  2441. function SHGetDataFromIDListA;        external shell32 name 'SHGetDataFromIDListA';
  2442. function SHGetDataFromIDListW;        external shell32 name 'SHGetDataFromIDListW';
  2443. function SHGetDataFromIDList;        external shell32 name 'SHGetDataFromIDListA';
  2444. function SHGetDesktopFolder;            external shell32 name 'SHGetDesktopFolder';
  2445. function SHGetInstanceExplorer;         external shell32 name 'SHGetInstanceExplorer';
  2446. function SHGetMalloc;                   external shell32 name 'SHGetMalloc';
  2447. function SHGetPathFromIDListA;        external shell32 name 'SHGetPathFromIDListA';
  2448. function SHGetPathFromIDListW;        external shell32 name 'SHGetPathFromIDListW';
  2449. function SHGetPathFromIDList;        external shell32 name 'SHGetPathFromIDListA';
  2450. function SHGetSpecialFolderLocation;    external shell32 name 'SHGetSpecialFolderLocation';
  2451. function SHLoadInProc;                  external shell32 name 'SHLoadInProc';
  2452.  
  2453. end.
  2454.  
  2455.  
  2456.